Skip to content

Commit

Permalink
added more firestore commands
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterHdd committed Sep 5, 2018
1 parent 1780bfd commit e65d4bc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -2,6 +2,7 @@
## VS Code Firebase and Firestore snippets
-------------------
[![Version](https://vsmarketplacebadge.apphb.com/version/peterhdd.firebase-firestore-snippets.svg)](https://marketplace.visualstudio.com/items?itemName=peterhdd.firebase-firestore-snippets)
[![Installs](https://vsmarketplacebadge.apphb.com/installs/peterhdd.firebase-firestore-snippets.svg)](https://marketplace.visualstudio.com/items?itemName=peterhdd.firebase-firestore-snippets)

## Supported Languages
* JavaScript (.js)
Expand Down Expand Up @@ -59,7 +60,7 @@
| `firedeleteuser` | Delete a user account with the delete method |
| `firesignout` | Sign out the user |
| `firegoogleinstance` | Get instance of the google provider |
| `fireprovidersignin` | eSign in with google |
| `fireprovidersignin` | Sign in with google |
| `firefacebookinstance` | Get instance of facebook provider |
| `firetwitterinstance` | Get instance of twitter provider |
| `firegithubinstance` | Get instance of github provider |
Expand All @@ -71,12 +72,15 @@
| -------: | ------- |
| `initializefirestore` | Initialize Cloud Firestore through Firebase |
| `adddatafirestore` | Creating a new collection and document in firestore |
| `setdatafirestore` | Creates or overwrite a single document, use the `set()` method |
| `readdatafirestore` | Read data from a collection in firestore |
| `referencefirestore` | Add firestore reference |
| `updatefirestore` | Update the document in firestore |
| `deletedocfirestore` | Delete a document in firestore |
| `deletefieldfirestore` | Delete a field in firestore document |
| `wherefirestore` | where query in firestore |
| `arraycontainsfirestore` | Using `array-contains` it filters based on array value |
| `limitfirestore` | Retrieves the first three value of the field |
| `ordermultifirestore` | Order by multiple fields in firestore |
| `realtimeupdatefirestore` | Listens for realtime changes on a document using `onSnapshot` |

34 changes: 33 additions & 1 deletion snippets/snippets.json
Expand Up @@ -467,6 +467,17 @@
],
"description":"Read data from a collection in firestore"
},

"firestore set data":{
"prefix":"setdatafirestore",
"body":[
"${0:db}.collection(${1:/* collection_name */}).doc(${2:/* document_name */}).set({",
"${3:attribute}: ${4:value}",
" });"

],
"description":"Creates or overwrite a single document, use the `set()` method"
},

"firestore reference":{
"prefix":"referencefirestore",
Expand Down Expand Up @@ -506,7 +517,7 @@
"firestore delete a field":{
"prefix":"deletefieldfirestore",
"body":[
"let ${0:ref}= ${0:db}.collection(${2:/* collection_name */}).doc(${3: /* document_name */});",
"let ${0:ref}= ${1:db}.collection(${2:/* collection_name */}).doc(${3: /* document_name */});",
"let ${4:removeField} = ${5:ref}.update({",
"${6:fieldName}: firebase.firestore.FieldValue.delete()",
" });"
Expand All @@ -523,6 +534,16 @@
],
"description":"where query in firestore"
},

"firestore array contains":{
"prefix":"arraycontainsfirestore",
"body":[
" ${0:ref}.where(${1:/* field name */}, ${2:array-contains}, ${3:/* value */})"
],
"description":" Using `array-contains` it filters based on array value"

},

"firestore limit":{
"prefix":"limitfirestore",
"body": "${0:ref}.orderBy(${1:/* fieldname */}).limit(${2: /* number */});",
Expand All @@ -534,6 +555,17 @@
"${0:ref}.orderBy(${1:/* fieldname */}).orderBy(${2: /* name */}, ${3: /* desc */});"
],
"description":"Order by multiple fields in firestore."
},

"firestore Listen to Changes":{
"prefix":"realtimeupdatefirestore",
"body":[
"${0:db}.collection(${1:/* collection_name */}).doc(${2:/* collection_name */})",
".onSnapshot(function(${3:doc}) {",
"console.log(${3:doc}.data());",
" });"
],
"description":"Listens for realtime changes on a document using `onSnapshot`"
}

}
Expand Down

0 comments on commit e65d4bc

Please sign in to comment.