I have the following data record stored in Algolia:
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"}
]
I would like to append the following object to the quotation array when the quotation collection is updated:
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",
});
I have attempted to use the following code from a Cloud Function to update the Algolia record:
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,
});
});
Despite following the example from Algolia, I encounter an error even before deploying the Cloud Function:
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 },
~~~~~~~
What could be the issue causing this error?