云Firestore深入与subcollection [英] Cloud Firestore deep get with subcollection

查看:206
本文介绍了云Firestore深入与subcollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一个名为todos的根集合。

这个集合中的每个文档都有:

ol>

  • title :String
  • 名为的子集合todo_items


  • 子集合 todo_items 中的每个文档都有




  • title :String
  • 完成


  • $ b

    我知道在Cloud Firestore中的查询默认很浅,有没有一种方法来查询 todos 并自动获得包含子集合 todo_items 的结果?



    换句话说,我如何使下列查询包含 todo_items 子集合?



    onSnapshot((snapshot)=> {
    snapshot.docChanges.forEach((change)=> {$ b $($ t pre $ p $ b // ...
    });
    });


    解决方案

    不支持这种类型的查询是我们未来可能考虑的事情。


    Let's say we have a root collection named 'todos'.

    Every document in this collection has:

    1. title: String
    2. subcollection named todo_items

    Every document in the subcollection todo_items has

    1. title: String
    2. completed: Boolean

    I know that querying in Cloud Firestore is shallow by default, which is great, but is there a way to query the todos and get results that include the subcollection todo_items automatically?

    In other words, how do I make the following query include the todo_items subcollection?

    db.collection('todos').onSnapshot((snapshot) => {
      snapshot.docChanges.forEach((change) => {
        // ...
      });
    });
    

    解决方案

    This type of query isn't supported, although it is something we may consider in the future.

    这篇关于云Firestore深入与subcollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆