Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. @override
  2. Future<List<Message>> getAttachments(String chatId, int type) async{
  3. print('for chat id $chatId $type');
  4.  
  5. DocumentReference chatDocRef =
  6. fireStoreDb.collection(Paths.chatsPath).document(chatId);
  7. CollectionReference messagesCollection =
  8. chatDocRef.collection(Paths.messagesPath);
  9. final querySnapshot = await messagesCollection
  10. .where('type',isEqualTo: type)
  11. .orderBy('timeStamp', descending: true) // order them by timestamp
  12. .getDocuments();
  13. List<Message> messageList = List();
  14. querySnapshot.documents
  15. .forEach((doc) => messageList.add(Message.fromFireStore(doc)));
  16. print('ret8urning messagelist ${messageList.length} for $type');
  17. return messageList;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement