问题描述
假设我们有一个名为todos的根集合。这个集合中的每个文档都有: 子集合
ol>
title
:String
的子集合todo_items $ c $
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:
title
: String- subcollection named
todo_items
Every document in the subcollection todo_items
has
title
: Stringcompleted
: 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!