【发布时间】:2018-03-19 02:40:34
【问题描述】:
我正在试用 Firebase 的新 Firestore。当我从https://firebase.google.com/docs/firestore/manage-data/add-data?authuser=0 运行代码示例时,出现错误。
// Add a new document with a generated id.
db.collection("cities").add({
name: "Tokyo",
country: "Japan"
})
.then(function(docRef) {
console.log("Document written with ID: ", docRef.id);
})
.catch(function(error) {
console.error("Error adding document: ", error);
});
异常捕获:(FirebaseError) : Function CollectionReference.add() 要求其第一个参数为 object 类型,但它是:自定义 Object 对象
编辑: 抱歉,我没有提到我正在使用 GWT 和 JSNI,没有 gwt 也可以正常工作
【问题讨论】:
-
通过快速扫描,您的代码看起来是正确的,这让我想知道是否从示例中复制了一些不可打印的字符。您可以尝试输入您传入的 JSON 对象,看看是否有影响?
-
我又打了一遍,没区别
-
嗯....在那种情况下我不知道。让我们希望其他人有更好的主意。
-
您找到解决此问题的方法了吗?我也遇到了同样的问题。
标签: javascript firebase gwt jsni google-cloud-firestore