[英]How to create a collection inside a document in Firestore with Flutter?
I'm working with a document and I want to create an empty collection inside the document.我正在处理一个文档,我想在文档中创建一个空集合。
FirebaseFirestore.instance.collection('Users').doc("thisdoc). ??? (create collection inside this document)
I don't know what to add instead of???我不知道要添加什么而不是???
The documentation will help you there.该文档将为您提供帮助。
NOTE The Firebase team is migrating these docs onto firebase.com directly, so this link may get old quickly in the next months.注意Firebase 团队正在将这些文档直接迁移到 firebase.com 上,因此此链接在接下来的几个月中可能会很快失效。
EDIT.编辑。 Since you need to create it under a subcollection, simply:
由于您需要在子集合下创建它,因此只需:
Pseudocode:伪代码:
// WARN, PSEUDOCODE AHEAD
final documentRef = firestore.collection("myCol").document("myDoc");
final subCollectRef = documentRef.collection("mySubCol");
subCollectRef.add({
'your': 'data',
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.