【问题标题】:Listen firestore by where condition from reference type通过引用类型的 where 条件监听 firestore
【发布时间】:2019-04-27 14:48:54
【问题描述】:

我正在学习颤振,并且也是 Firestore 的新手,尝试实施并遇到这种情况。

我有带有文档 ID 的 Account 文档是像 KCeEhT9NwFURl0xirRrU 这样的生成器,而 Book 文档必须引用 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】:

    试试

      where("email", "==", email)
    

    【讨论】:

    • 谢谢,但在 Dart 中不要使用这种语法。
    猜你喜欢
    • 2018-12-14
    • 2019-05-24
    • 1970-01-01
    • 1970-01-01
    • 2019-10-24
    • 1970-01-01
    • 2021-06-04
    • 2013-05-28
    • 1970-01-01
    相关资源
    最近更新 更多