I have a JSON object coming from a Firebase (Firestore) query.
let json = [{
"historical_data": {
"created_by": "HKyUyCuVj0g12htOsAPmGCcffBq2",
"created_at": {
"seconds": 1606403054,
"nanoseconds": 416000000
}
}
}];
I need to update the created_at value to a Firestore server timestamp.
Therefore I would iterate and update the respective field like this:
for (var i in json) {
var item = json[i];
item.historical_data.created_at = firebase.firestore.FieldValue.serverTimestamp();
}
Although VS Code is giving me the following error message:
Type 'FieldValue' is missing the following properties from type '{ seconds: number; nanoseconds: number; }': "seconds", "nanoseconds"
I understand the error and why it's happening, so is there any way to update the JSON and change or cast the type of created_at to another one?