Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. static async createAlert(alertSchema) {
  2. return new Promise((resolve, reject) => {
  3. if (!testAlert(alertSchema)) {
  4. reject({error: testAlert.errors})
  5. }
  6. const alertsCollection = db.collection('serviceRequests')
  7. alertsCollection.add(alertSchema).then(ref => {
  8. resolve(ref)
  9. })
  10. .catch(err => {
  11. reject(err)
  12. })
  13. })
  14. }
  15.  
  16. static async deleteAlert(alertRef) {
  17. return new Promise((resolve, reject) => {
  18. const alertsCollection = db.collection('serviceRequests')
  19. alertsCollection.doc(alertRef).delete().then(ret => {
  20. resolve(ret)
  21. }).catch(err => {
  22. reject(err)
  23. })
  24. })
  25. }
  26.  
  27. // TODO: besoin de la fonction getCurrentUserFamily()
  28. /*
  29. static async getAlertFromCurrentUserFamily() {
  30. return new Promise((resolve, reject) => {
  31. const alertsCollection = db.collection('serviceRequests')
  32. const uid = auth.currentUser.uid
  33.  
  34. alertsCollection.doc("lol").get().then(l => {
  35. resolve(l)
  36. }).catch(err => {
  37. reject(err)
  38. })
  39.  
  40. })
  41. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement