【发布时间】:2018-11-05 10:10:40
【问题描述】:
我正在使用Angular 6 和Firestore 开发一个应用程序,我将我的日期保存为Javascript 的Date 对象。问题是当我执行 snapshotChanges() 时,它返回一个 Unix Timestamp 而不是我数据库中的 Date 对象。
我在网上搜索了解决方案(this、and this)并找到了 Firestore 的这个配置选项:
{ timestampsInSnapshots: false }
我正在尝试将它应用到我的应用组件中,如下所示:
constructor(private _db: AngularFirestore) {
_db.firestore.settings({ timestampsInSnapshots: false });
}
但后来我得到了这个错误:
Firestore has already been started and its settings can no longer be changed. You can only call settings() before calling any other methods on a Firestore object.
我也尝试在调用 snapshotChanges() 之前更改设置,但这也不会对行为产生任何影响。
注意:我也在使用AngularFirestoreModule.enablePersistence()
更新:
我试过this,它给了我这个错误:
@firebase/firestore: Firestore (5.0.3):
The behavior for Date objects stored in Firestore is going to change
AND YOUR APP MAY BREAK.
任何建议都会很棒。
【问题讨论】:
标签: angular firebase google-cloud-firestore angular6