我在查询 Firestore 数据库中子集合内的所有文档时遇到困难。(我正在使用 Node.js)
我的目标是从名为的子集合中的每个文档获取所有数据favorites
我的数据库结构如下所示。

我查看了https://firebase.google.com/docs/firestore/query-data/get-data上的文档,但没有任何结果如何解决问题。
我的查询现在看起来像这样:
exports.getAllFavoritePodcasts = (req, res) => {
db.collection('users')
.doc(req.user.userId)
.collection('favorites')
.then(snapshot => {
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data());
});
})
.catch(err => {
console.log('Error getting documents', err);
});
}
Run Code Online (Sandbox Code Playgroud)
但我得到TypeError: db.collection(...).doc(...).collection(...).then is not a function
javascript node.js firebase google-cloud-platform google-cloud-firestore
我的项目结构是这样的:
我正在尝试同时启动我的 Node Express Server 和 React 项目。但只有快速服务器正在启动。我不知道如何 cd 到 /client。
这是我在 /server/package.json 中的 package.json:
{
"name": "podifi",
"version": "1.0.0",
"scripts": {
"client": "cd client && npm run start",
"server": "nodemon server.js",
"dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\""
},
Run Code Online (Sandbox Code Playgroud)
它应该是什么而不是:"client": "cd client && npm run start",??