没有关于如何在Firestore中的文档中添加子集合的文档,那么如何使用Web应用程序添加子集合?
我尝试了这个但没有成功:
如何使用代码在应用程序中添加子集合?有什么办法可以做到这一点,或者使用 Firebase 实时数据库会更好吗?
如果是这样,请让我知道如何在 Firebase 中执行此操作。
我想这样添加:
我这样做了:
但我收到此错误:
如果你改变你的代码应该可以工作.set
to .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
})
本页详细介绍了如何将数据添加到 Cloud Firestore https://firebase.google.com/docs/firestore/manage-data/add-data
添加一本书
db.collection('users').doc(this.username).collection('booksList').add({
password: this.password,
name: this.name,
rollno: this.rollno
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)