从引用类型的条件监听firestore

问题描述 投票:0回答:1

我正在学习扑克,也是新的火器店,尝试实施并得到这种情况。

我有文件ID的Account文件是像KCeEhT9NwFURl0xirRrUBook文件的生成器,必须与Account一起参考,现在我想通过电子邮件创建一个监听Book的任何更改与特定帐户,我尝试但不工作。

var accountRef = firestore.collection('Account')
  .where("email", isEqualTo: email)
  .reference()
  .document();
firestore.collection('Book')
  .where('assigner', isEqualTo: accountRef)
  .where('status', isGreaterThan: 0)
  .snapshots()
  .listen((query) async {
    List<Book> books = <Book>[];
    for (var documentChange in query.documentChanges) {
      var book = await Book.fromMap(documentChange.document.data);
      books.add(book);
    }
    print(books);
  }
);

如果我使用它,它可以工作,但我不记得文档ID

var accountRef = firestore.collection('Account').document('KCeEhT9NwFURl0xirRrU');

我只想通过电子邮件过滤,任何帮助,谢谢。

dart flutter google-cloud-firestore
1个回答
0
投票

尝试

  where("email", "==", email)
© www.soinside.com 2019 - 2024. All rights reserved.