gpt4 book ai didi

Firebase Firestore 显示警告

转载 作者:行者123 更新时间:2023-12-01 07:51:14 24 4
gpt4 key购买 nike

我正在做一个使用 ionic 3 和 firebase firestore 作为数据库的项目。

但是每当我进行 CRUD 操作时,我的 firebase firestore 都会显示警告。

 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.

最佳答案

我在 app.module.ts 中添加了以下代码,然后错误更正。
firebase.initializeApp(environment.firebase)//加载 firebase 服务器设置

firebase.firestore().settings( { timestampsInSnapshots: true })

关于Firebase Firestore 显示警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50128137/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com