没有关于如何在 firestore 的文档中添加子集合的文档, 如何使用 Web 应用程序添加子集合? even tried like this but didn't worked . 如何使用代码在应用程序中添加子集合? 有什么办法吗,或者使用firebase实时数据库会更好? 如果是这样,请让我知道如何在 Firebase 中进行操作 i want to add like this i did this但我收到这样的错误 the error says this
最佳答案
如果您将 .set
更改为 .add
,您的代码应该可以工作。然后,Cloud Firestore 将为该文档颁发一个新 ID。如果要指定文档 ID,则需要执行此操作...
设置具有给定 ID 的图书
db.collection('users').doc(this.username).collection('booksList').doc(myBookId).set({
password: this.password,
name: this.name,
rollno: this.rollno
})
此页面详细介绍如何 Add data to Cloud Firestore
添加一本书
db.collection('users').doc(this.username).collection('booksList').add({
password: this.password,
name: this.name,
rollno: this.rollno
})
关于javascript - 如何将子集合添加到 Firestore 中的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48873465/