繁体   English   中英

Flutter firestore 字符串转换为 where 子句的文档参考

[英]Flutter firestore string convert to document reference for where clause

我的聊天集合有一个字段 event_id 并且它的类型现在是引用我想使用我的事件文档 ID 进行查询如何将字符串转换为 DocumentReference 类型以便我可以传递到 where 子句并通过聊天集合进行查询

chat.where('event_id', isEqualTo:'events/J3HTFRpL0H').snapshots(),

因为它已经是 DocumentReference,所以您可以简单地执行eventRef.snapshots() ,假设eventRef是事件的 DocumentReference。

如果获取的事件引用数据是字符串,则需要先将其转换为 DocumentReference,例如eventRef = eventStr as DocumentReference; ,假设eventStr是表示事件文档的 DocumentReference 的字符串。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM