Firebase Firestore Showing Warning


#1

I have a project and its database is located in firestore. I can make CRUD operation with firestore without any problem.But now I got a warning.but Even the warning exists I can make the CRUD operation.The warning is given below

index.esm.js:77 [2018-05-02T05:45:40.408Z] @firebase/firestore: Firestore (4.13.0):
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. 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.

why this kind of warning occur and how can i remove it…?


#2

Try:


...

import { AngularFireModule } from 'angularfire2';
import { AngularFirestore, AngularFirestoreModule } from 'angularfire2/firestore';
import { AngularFireAuthModule } from 'angularfire2/auth';

import { ENV } from '@env';

...

@NgModule({
  imports: [
    CommonModule,
    IonicModule,
    AngularFireModule.initializeApp(ENV.firebase),
    AngularFirestoreModule,
    AngularFireAuthModule,

    ...

    ServiceWorkerModule.register('/ngsw-worker.js', { enabled: ENV.production })
  ],
  exports: [],
  declarations: [],
  providers: [

   ...

  ]
})
export class CoreModule {

  constructor(@Optional() @SkipSelf() parentModule: CoreModule,
              private afs: AngularFirestore) {

    throwIfAlreadyLoaded(parentModule, 'CoreModule');

    const settings = { timestampsInSnapshots: true };
    afs.app.firestore().settings(settings);
  }

}

#3

ok…thanks But what is the reason for this warning…?

is it related with firestore or Ionic…?


#4

“The behavior for Date objects stored in Firestore is going to change”

“With this change, timestamps stored in Cloud Firestore will be read back as Firebase Timestamp objects instead of as system Date objects.”


#5

Thanks i got it …really helpful