The behavior for Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK
[REQUIRED] Step 2: Describe your environment
- Operating System version: Firebase cloud functions (node 6).
- Firebase SDK version:
- Library version: 5.12.1
- Firebase Product: firestore
[REQUIRED] Step 3: Describe the problem
Getting errors when initializing the firestore() module. Not sure what is the correct way to pass the settings objects when using firestore with the admin library.
On the client side I can just use firebase.firestore().settings({ timestampsInSnapshots: true });, but I can't find the correct way to do the same thing with the admin package. The suggested fixing method in the error log does not seem to relate to using firestore with the admin package.
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 = new 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. So you will also
need to update code expecting a Date to instead expect a Timestamp. For example:
// Old:
const date = snapshot.get('created_at');
// New:
const timestamp = snapshot.get('created_at');
const date = timestamp.toDate();
Please audit all existing usages of Date when you enable the new behavior. In a
future release, the behavior will change to the new behavior, so if you do not
follow these steps, YOUR APP MAY BREAK.
Steps to reproduce:
Initialize admin.firestre() in a cloud function.
Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.
Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.
Got it to work after updating to the latest version.
I still have this issue too, even after updating
Its whenever you request a firestore document that has a timestamp value. This value is created on the document through the web portal
Still have this issue with "firebase-admin": "^6.5.1"