我在算法中有以下记录
enterprise_name:"manaslu enterprise",
objectID:"14417261",_quotation:[{shamagri_title:"paper ad",price:4000,
unit:"per sq inc",
description:"5*5",
geo_latitude:40,
geo_longitude:89,
type:"service"}
]
我想在报价集合更新时将以下对象添加到报价数组中。
const enter = db.collection("quotation").doc("14417261");
return enter.update({
shamagri_title: "banner ad",
rate: 4000,
unit: "per sq inch",
description: "15 * 10",
type: "service",
});
我已经尝试使用以下来自云功能的代码来更新算法记录
functions.firestore
.document("quotation/{quotationId}")
.onUpdate((change) => {
const newData = change.after.data();
const objectID = change.after.id;
return index.partialUpdateObjects({
_quotation: {
_operation: "Add",
value: newData,
},
objectID,
});
});
基于firebase云功能,它确实根据更新提供了objectId我使用了上面的部分UpdateObjects函数,基于以下来自算法的示例
index.partialUpdateObject({
_tags: {
_operation: 'AddUnique',
value: 'public',
},
objectID: 'myID',
})
.then(({ objectIDs }) => {
console.log(objectIDs);
});
然而,在我部署云功能之前,我得到了以下错误
Argument of type '{ _quotation: { _operation: string; value: FirebaseFirestore.DocumentData; }; objectID: string; }' is not assignable to
parameter of type 'readonly Record<string, any>[]'.
Object literal may only specify known properties, and '_quotation' does not exist in type 'readonly Record<string, any>[]'.
19 _quotation: {
~~~~~~~~~~~~~
20 _operation: "Add",
~~~~~~~~~~~~~~~~~~~~~~~~~~
21 value: newData,
~~~~~~~~~~~~~~~~~~~~~~~
22 },
~~~~~~~
这里可能出了什么问题?
我通过使用CCD_ 1而不是用于更新一个以上记录的CCD_。在算法中,对象和对象对单个和多个记录更新产生了巨大的差异