Guest User

Untitled

a guest
Jan 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. function handleDeletedMessage(req, res) {
  2. var db = firestore.firestore();
  3.  
  4. db.collection("GroupMessages")
  5. .doc(req.params.groupConvoId)
  6. .collection("Messages")
  7. .doc(req.params.deletedMessageId)
  8. .get()
  9. .then(snapshot => {
  10.  
  11. if (snapshot.exists) {
  12. db.collection("GroupMessages")
  13. .doc(req.params.groupConvoId)
  14. .collection("Messages")
  15. .orderBy("createdAt", "desc")
  16. .where("wasRemoved", "==", false)
  17. .endBefore(snapshot.data().createdAt)
  18. .limit(3)
  19. .get()
  20. .then(docSnapshot => {
  21. console.log(docSnapshot); // size here is always 0
  22.  
  23. if (docSnapshot.size > 0) {
  24. res.success();
  25. } else {
  26. res.error("nothing");
  27. }
  28.  
  29.  
  30. }).catch(error => {
  31. console.log(`There was an error getting the deleted message inner: ${error}`);
  32.  
  33. res.error("Unable to get deleted message");
  34. assert.ok(true);
  35. });
  36.  
  37.  
  38. } else {
  39. res.error("Unable to get deleted message snapshot");
  40. }
  41.  
  42. }).catch(error => {
  43. console.log(`There was an error getting the deleted message: ${error}`);
  44.  
  45. res.error("Unable to get deleted message");
  46. assert.ok(true);
  47. });
Add Comment
Please, Sign In to add comment