addDeposit(account, deposit) {
let depositsDoc = this.db.collection("accounts")
.doc(account.id)
.collection("deposits")
.doc("deposits");
return new Promise((resolve, reject) => {
deposit.created_at = firebase.firestore.FieldValue.serverTimestamp();
depositsDoc.update({
"deposits": firebase.firestore.FieldValue.arrayUnion(deposit)
})
.then((a) => {
resolve('success');
})
.catch((error) => {
reject("failed");
});
})
.then((res) => {
return res;
})
.catch((error) => {
return error;
})
}
**Firestore with angular (Using default firebase SDK not angularfire ) **
I was trying to add timestamp to the deposit object by directly adding a "created_at" property calling the timestamp. By doing this, I am getting the error titled above. How can I add timestamp to a object in an array of objects in firestore?