Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. // Setup Firestore. Note that all of these will be asyncronous tasks and can have a .then attached. Write in a config process for Firebase. Include the necessary process.env files and instructions how to make a .env file.
  2.  
  3. ***************************************************************
  4.  
  5. // Add data - C
  6. firestore.collection("CollectionName").add({
  7. key: value,
  8. key: value,
  9. })
  10.  
  11. ***************************************************************
  12.  
  13. // Getting data - R
  14. firestore.collection("CollectionName").get().then((snapshot) => {snapshot.docs.map(doc => {
  15. console.log(doc)
  16. })
  17. });
  18.  
  19. !!------------------------!!
  20. // If you require a search query
  21.  
  22. firestore.collection("CollectionName").where("key", "==", "value").get();
  23.  
  24.  
  25. ***************************************************************
  26.  
  27. // Update data - U
  28. firestore.collection("CollectionName").doc(ID).update({
  29. key: newValue
  30. });
  31.  
  32. ***************************************************************
  33.  
  34. // Deleting data - D
  35. firestore.collection("CollectionName").doc(ID).delete()
  36.  
  37. ***************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement