Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. senderid : this.buddy.senderId,
  2. receiverid: this.buddy.receiverId,
  3. message : msg,
  4. created: firebase.firestore.FieldValue.serverTimestamp()
  5.  
  6. this.db.collection(this.collectionName.friendsCollection).doc(this.buddy.docid)
  7. .collection(this.collectionName.chatsCollection).orderBy('created')
  8. .onSnapshot(snapshot=> {
  9. skip.buddymessages = [];
  10. if(snapshot.empty)
  11. {
  12. console.log("First Chat");
  13. }
  14. else{
  15. console.log("size",snapshot.size)
  16. snapshot.docChanges.forEach(change => {
  17. if (change.type === 'added') {
  18. console.log('New : ', change.doc.data());
  19. }
  20. if (change.type === 'modified') {
  21. console.log('Modified : ', change.doc.data());
  22. }
  23. if (change.type === 'removed') {
  24. console.log('Removed : ', change.doc.data());
  25. }
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement