【发布时间】:2020-07-30 17:59:33
【问题描述】:
我在 JS 中生成了一个地图dataMap,它在控制台上如下所示:
dataMap: { val1 → "50", item1 → "shoe", val2 → "20", item2 → "book" }
当我尝试将其写入云 Firestore 时
db.collection("readDynamic").add({
name: 'Alex',
items: dataMap,
age: '24'
})
.then(function (querySnapshot) {
if (querySnapshot.size) {
querySnapshot.forEach(function (data) {
console.log("Document successfully updated!");
console.log(data.id, " => ", data.data());
});
}
})
.catch(function(error){
console.log("error!", error);
})
报错:
未捕获的 FirebaseError:使用无效数据调用函数 DocumentReference.set()。不支持的字段值:自定义 Map 对象
我做错了什么?
【问题讨论】:
标签: javascript firebase google-cloud-firestore hashmap