Firebase querySnapshot not updating realtime with where condition

允我心安 提交于 2021-01-28 03:41:54

问题


I am using cloud firestore with flutter to store the chat and using where condition to get the chats. the documents returns correctly but when the new data is added the chat list will not update in realtime.

How the chat is stored:- collection -> message {message, timestamp, sentBy,sentTo} are the message fields

the query is

firestore
        .collection('chats_v2')
        .where('sentBy', isEqualTo: 'abc')
        .where('sentTo', isEqualTo: 'xyz')
        .orderBy('timestamp')
        .snapshots();

The Chat loads perfectly for first time, but when the new message is added to collection list wont update

I also tried, this dint work:

firestore
        .collection('chats_v2')
        .where('trackId', isEqualTo: trackId)
        .where('groupId', isEqualTo: groupId)
        .orderBy('timestamp')
        .snapshots().listen((data){
          //return the QuerySnapshot from here to StreamBuilder;
        });

来源:https://stackoverflow.com/questions/62514221/firebase-querysnapshot-not-updating-realtime-with-where-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!