Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore error/warning message #38

Open
185driver opened this issue Jul 19, 2018 · 1 comment
Open

Firestore error/warning message #38

185driver opened this issue Jul 19, 2018 · 1 comment

Comments

@185driver
Copy link

I'm getting this Firestore error/warning at the top of the cmd window when running the plugin:

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.

Is this message being generated by Firestore in response to something coded within the plugin?

@kitfit-dave
Copy link

Like the error message says, you need to pass timestampsInSnapshots to Firestore.settings().
I have a PR that simply does that. One might prefer to allow other settings to be set also, but this at least fixes the (many lines long) warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants