Because of the warning about the upcoming change in timestamp behavior in Firestore, I am trying to change the initialisation code for my app.
The behavior for Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK. To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods:
const firestore = firebase.firestore(); const settings = {/ your settings... / timestampsInSnapshots: true}; firestore.settings(settings);
With this change, timestamps stored in Cloud Firestore will be read back as Firebase Timestamp objects instead of as system Date objects.
I can't find any reference to firestore "settings" though. Would something like this work? The Typescript definition says no...
import * as admin from "firebase-admin";
export const adminApp = admin.initializeApp();
const firestore = admin.firestore(adminApp);
firestore.settings({ timestampsInSnapshots: true });
I've upgraded the firebase-admin to 5.13.0 and with the following node.js code in my index.js after initializeApp(), that warning went away and my code runs correctly afterwards.
admin.initializeApp();
const settings = {/* your settings... */ timestampsInSnapshots: true};
admin.firestore().settings(settings);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With