Open iKK001 opened 9 months ago
Hi ! I have a similar issue: On project 1 (WORKS):
import * as admin from 'firebase-admin';
item.date = new admin.firestore.Timestamp(timestampData);
await admin.firestore().collection('test').doc(test.id).update({ item: item });
"firebase-admin": "^9.8.0"
On project 2 (DOESN'T WORK):
import * as admin from 'firebase-admin';
const { Timestamp } = require('@google-cloud/firestore'); // Had to change here because previous one was making error
item.date = new Timestamp(timestampData);
await admin.firestore().collection('test').doc(test.id).update({ item: item });
Error: Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Value for argument "dataOrField" is not a valid Firestore document. Detected an object of type "Timestamp" that doesn't match the expected instance (found in field "item.date"). Please ensure that the Firestore types you are using are from the same NPM package.)
"firebase-admin": "^11.5.0"
In the end I followed this guy solution: https://stackoverflow.com/questions/68384853/firebase-firestore-timestamp-fromdate-is-undefined and save the date as a JS date
item.date = new Date(timestampData._seconds * 1000);
The update method of
BaseFirestoreRepository
offireorm
cannot deal with a date that is created with neest 'firebase-admin' SDK v11.11.1 anymore. (i.e.update(item: T): Promise<T>;
)Before, with
firebase-admin
SDK version 11.9.0, everything worked:This works with v11.9.0:
But now, with
firebase-admin
SDK version 11.11.1, the collection-udpate crashes:The error message is:
After some more investigation:
The way it still works is as follows !!!!!!
Summary:
@google-cloud/firestore 7.1.0 WORKS (calling
updateTruc.changedAt = Timestamp.fromDate(new Date());
)firebase-admin 11.9.0 WORKS (calling
updateTruc.changedAt = firestore.Timestamp.fromDate(new Date());
)firebase-admin 11.11.1 DOES NOT WORK !!!!!! (calling
updateTruc.changedAt = Timestamp.fromDate(new Date());
)It seems that
fireorm
can only handle Timestamps from @google-cloud/firestore - but no longer with newest version of firebase-admin v11.11.1. (It was able to do it with firebase-admin v10.9.0 - but no longer with v11.11.1 anymore).So clearly, the firebase-admin SDK added an incompatibility for dates with respect to fireorm updates.
Can
fireorm
please be fully compatible again to newestfierebase-admin
SDK ??Or what 's the problem suddenly with
firebase-admin
v11.11.1 ??