我使用以下代码创建了一个messages
集合;
var documentReference = Firestore.instance
.collection('messages')
.document(groupChatId)
.collection(groupChatId)
.document(DateTime.now().millisecondsSinceEpoch.toString());
Firestore.instance.runTransaction((transaction) async {
await transaction.set(
documentReference,
{
'idFrom': _cuserID,
'idTo': chatWith,
'timestamp': DateTime.now().millisecondsSinceEpoch.toString(),
'content': content,
'type': type,
'hasRead': false
},
);
});
我想查询上面的集合,选择与where
查询匹配的文档。
下面是到目前为止的代码,请帮忙;
QuerySnapshot myChats =
await Firestore.instance.collection('messages').where('idTo', isEqualTo: currentUser.uid).getDocuments();
我会输入在创建期间使用的文档值groupChatId
和集合值groupChatId
,但是由于它们不是唯一的,因此无法检索它们。