简体   繁体   English

如何创建子集合到 firebase firestore 文档

[英]How to create sub collection to firebase firestore document

Is there a way to create sub collection after set() method like shown below?有没有办法在 set() 方法之后创建子集合,如下所示?

在此处输入图像描述

                    CollectionReference ref1 =
                        FirebaseFirestore.instance.collection('chatrooms');
                    await ref1
                        .doc(chatroom)
                        .set({"chatid": chatroom})
                        .collection('messages')
                        .add({"message": _message.text});
    CollectionReference ref1 =
    FirebaseFirestore.instance.collection('chatrooms');
await ref1.doc('doc').set({"chatid": chatroom});
await ref1
    .doc('doc')
    .collection('messages')
    .add({"message": _message.text});

U can split it like this你可以这样拆分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM