简体   繁体   English

Flutter 对文档数组字段的firestore查询

[英]Flutter firestore query on document array field

I've got this firestore database.我有这个firestore数据库。

There is a 'users' collection containing documents of users.有一个包含用户文档的“用户”集合。 Each user has their own information such as name and a cart.每个用户都有自己的信息,例如姓名和购物车。 I would like to get all the 'carts' of a particular user in a stream.我想在 stream 中获取特定用户的所有“购物车”。 How would you go about with the query?您将如何查询 go?

await FirebaseFirestore.instance.Collection("users").doc("docIdHere").get().then((. 
document) {
//it will get the first item in the cart with index zero
document.get("cart")[0];
//then do what you want
});

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

相关问题 Flutter:如何获取 Firestore 文档中字段(列表)的长度? - Flutter : How to get the length of field (list) in Firestore document? 添加到特定文档的 map 字段 (Flutter Firestore) - Adding onto a map field of a specific document (Flutter Firestore) Firestore 通过数组的字段值进行查询 - Firestore to query by an array's field value flutter:从 firestore 的数组字段中获取用户列表及其数据 - flutter: getting a list of users and their data from the array field in firestore flutter firestore 未在云 firestore 数据库中创建文档 - flutter firestore not creating a document in the cloud firestore database Flutter Firestore:将数据列表添加到 Firestore 文档 - Flutter Firestore : Add a List of Data to Firestore Document 如何在 Firestore 中更改文档数组字段的某个索引的值? - How to change the value of a certain index of an array field of a document in Firestore? 如何获取在 flutter 中具有特定字段值的 Firestore 文档的 DocumentID? - How do I get the DocumentID of a firestore document that has a particular field value in flutter? Firestore 查询,其中结果有一个字段,该字段包含要传递给第二个查询以检索所有文档的文档引用 - Firestore query where the results have a field that contains a document ref to be passed to a second query to retrieve all the documents 查询文件 ID 的 firestore 数据库 - Query firestore database for document id
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM