我的Firestore云功能中出现此错误。我正在使用WebStorm和node.js。我不知道为什么它不起作用..
如果有人知道为什么会这样,我将不胜感激!
这是我的功能:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.httpTest = functions.https.onRequest((req, res) => {
const db = admin.firestore();
const articlesRef = db.collection('articles_common');
const query = articlesRef.where('locked', '==', false).get()
.then(snapshot => {
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data());
});
})
.catch(err => {
console.log('Error getting documents', err);
});
res.send("Http test function");
console.log( "HttpTest - Cron-job.org triggered ")
});
Run Code Online (Sandbox Code Playgroud) node.js webstorm firebase google-cloud-functions google-cloud-firestore
我有这个数据库结构:
Firestore-root
|
--- sites (collection)
| |
| --- common (document)
| |
| --- //templates (collection)
| |
| --- //menus (collection)
| |
| --- //articles (collection) <----
| --- other (document)
| |
| --- //articles (collection)
Run Code Online (Sandbox Code Playgroud)
当我尝试将文章添加到数据库(如箭头所示)时,“common”和“other” - 文档为斜体,因此不存在。
我尝试添加时的代码:优先级很常见,类型是文章。
def documentReference = firestoreClient.databaseReference.collection(siteName).document(priority).collection(TYPE).document(key)
documentReference.set(article)
Run Code Online (Sandbox Code Playgroud)
这是控制台:

这是构建我的数据库的糟糕方法还是有快速修复?
我曾尝试先创建子集合,但没有任何运气!