Skip to content
This repository has been archived by the owner on Jun 3, 2019. It is now read-only.

Change version to 1.0.4 #12

Open
pippo111 opened this issue Jan 8, 2019 · 2 comments
Open

Change version to 1.0.4 #12

pippo111 opened this issue Jan 8, 2019 · 2 comments

Comments

@pippo111
Copy link

pippo111 commented Jan 8, 2019

Can somebody change plugin version so we can install it with latest changes, please ?

@ryanbraving
Copy link

@alvinthen
I get the below warning at the start when I run gatsby develop. Can you update your plugin please?
Here is the warning:

⠂ source and transform nodes
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.

@m4rrc0
Copy link

m4rrc0 commented Mar 16, 2019

+1
Though, this is a breaking change so it should probably be a version 2.0.0
To make it non-breaking, the plugin should automatically transform every timestamp to date I suppose. But I don't think it is desirable.

In the meantime, @pippo111 , @ryanbraving you could

yarn add taessina/gatsby-source-firestore#master

Make sure to handle timestamps properly. My gatsby config looks something like that:

    {
      resolve: 'gatsby-source-firestore',
      options: {
        credential: firestoreCredential,
        types: [
          {
            type: 'FirestoreEvent',
            collection: 'events',
            map: ({
              timeStart,
            }) => ({
              timeStart: timeStart.toDate(),
            }),
          },
        ],
      },
    },

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

No branches or pull requests

3 participants