Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 我试图使用集合中的字段';简介';说';用户名';要从主集合中筛选记录';订单';_Flutter_Google Cloud Firestore - Fatal编程技术网

Flutter 我试图使用集合中的字段';简介';说';用户名';要从主集合中筛选记录';订单';

Flutter 我试图使用集合中的字段';简介';说';用户名';要从主集合中筛选记录';订单';,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,有没有办法做到这一点? 我曾尝试将条目分配给局部变量,但它不适用于crudmethods getData() async { String userId = 'userId'; Firestore.instance.collection('user').document(userId).snapshots(); var snapshot; var userDocument = snapshot.data; String _myAddress = userD

有没有办法做到这一点? 我曾尝试将条目分配给局部变量,但它不适用于crudmethods

getData() async {
    String userId = 'userId';
    Firestore.instance.collection('user').document(userId).snapshots();
    var snapshot;
    var userDocument = snapshot.data;
    String _myAddress = userDocument["address"];
    return Firestore.instance
        .collection('letters')
        .where("source Box", isEqualTo: _myAddress)
        .snapshots();
  }

是的,您应该能够在查询其他文档时使用文档。 为此,您需要为一个集合创建一个引用,并在另一个集合中使用它

下面的代码是一个示例,您可以尝试根据您的情况进行进一步调整,但我相信这会对您有所帮助

// Create references to the profile and orders collections
var profilesRef = db.collection("profile");
var ordersRef = db.collection("orders");

// Create a query against the collection.
var query = ordersRef.where("username", "==", ).doc("username").get();
在文档中,有更多的信息和查询示例可以帮助您

// Create references to the profile and orders collections
var profilesRef = db.collection("profile");
var ordersRef = db.collection("orders");

// Create a query against the collection.
var query = ordersRef.where("username", "==", ).doc("username").get();
除此之外,下面这篇来自社区的帖子也可以为您提供一些关于如何实现此类查询的见解


如果这些信息对你有帮助,请告诉我

如果您提供他们可以轻松理解并用于重现问题的代码,人们将能够更好地提供帮助。我正试图在弗利特上实现这一点。你有什么见解吗?嗨@JustinWaweru for flatter,我建议你看看这篇文章和这篇文章,其中有一些关于flatter查询的有用案例,你可以查看。