gpt4 book ai didi

firebase - 向Firestore添加字段?

转载 作者:行者123 更新时间:2023-12-03 09:54:51 27 4
gpt4 key购买 nike

如图所示,我有一个名为JobsPosted的字段,所以我想添加另一个作业,我已经有洗碗机和侍者了。但是我收到此查询错误

     db.collection("companies").doc("Tiradito").field("jobsPosted").set(postJobObject).then(function() {
console.log("Document successfully written!");
});

那是我的帖子
var postJobObject = {
"position": this.state.selected,
"timeSchedule": this.state.timeSchedule,
"compensation" : this.state.compensation,
"experience" : this.state.experience,
"description" : this.state.description
}

最佳答案

传递选项以将新数据与任何现有文档合并,以避免覆盖整个文档

var cityRef = db.collection('cities').doc('BJ');

var setWithMerge = cityRef.set({
capital: true
}, { merge: true });

资料来源: https://firebase.google.com/docs/firestore/manage-data/add-data

关于firebase - 向Firestore添加字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47988466/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com