我試圖弄清楚如何在 Firestore 的以下目錄中構建一個新的子集合(紅色圓圈):目錄:“課程/{userID}/{courseID}”courseID 是在“userID”文檔中創建子集合時隨機生成的 ID。不幸的是,我能夠使用 .set() 運行的代碼不會創建新的子集合,而只是更新當前文檔。是否有可用于在文檔中創建新集合的函數?代碼:export const createCourse = (course) => { (...) //firestore.collection("courses").doc(authorId).set({ <---This commented out line updates the document, yet I'm trying to construct a new sub-collection inside this document, not just change fields inside of it. firestore.collection("courses").doc(authorId).add({ <--- This gives me an error stating " firestore.collection(...).doc(...).add is not a function ". I am trying to figure out what is the correct syntax for this intended action. ...course, authorUID: authorId, courseCreatedAt: new Date() }).then(() => { (...)};
我可以構建一個子集合嗎?(消防站)
慕村225694
2022-12-29 15:53:36