在控制台中获取'timestampsInSnapshots设置现在默认为true'firestore错误

问题描述 投票:9回答:1

我在Angular的控制台中从Firestore收到以下错误。

@firebase / firestore:Firestore(5.8.3):timestampsInSnapshots设置现在默认为true,您不再需要显式设置它。在将来的版本中,该设置将被完全删除,因此建议您立即从firestore.settings()调用中删除它。

有什么建议,怎么摆脱它?

angular google-cloud-firestore
1个回答
31
投票

转到app.modules.ts文件并添加导入:

import { FirestoreSettingsToken} from '@angular/fire/firestore';

然后在provider数组中添加此值:

providers: [{ provide: FirestoreSettingsToken, useValue: {} }]

0
投票

通常,我们通过以下方式在应用程序中配置firebase:

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

对于上面的配置,它显示以下警告:

@firebase/firestore: Firestore (6.3.5): The timestampsInSnapshots setting now defaults to true and you no longer need to explicitly set it. In a future release, the setting will be removed entirely and so it is recommended that you remove it from your firestore.settings() call now.

为了解决它,只需从timestampsInSnapshots参数中删除settings属性即可。修复后,您的配置应更改为:

firebase.firestore().settings({});
© www.soinside.com 2019 - 2024. All rights reserved.