【发布时间】:2018-11-13 13:12:30
【问题描述】:
我正在用 JavaScript 编写代码。我有这个 if 语句:
var rightsRef = db.collection("users").document(uid).collection("rights");
if(createDocumentWithId(rightsRef, "readGrades", "false", null, null, null, null) === true) {
window.location.href = "../public/main/main_index.html";
}
下面是应该在 cloud firestore 中添加值的函数:
function createDocumentWithoutId(var databaseRef, var titleValue1, var contentValue1, var titleValue2, var contentValue2, var titleValue3, var contentValue3) {
databaseRef.add({
titleValue1: contentValue1,
titleValue2: contentValue2,
titleValue3: contentValue3,
}).then(function() {
return true;
}).catch(function(error) {
console.error("Error adding document: ", error);
return false;
});
}
但我收到此错误:
TypeError: db.collection(...).document is not a function
【问题讨论】:
标签: javascript firebase google-cloud-firestore