sách gpt4 ăn đã đi

node.js - Làm cách nào để đặt cài đặt dấu thời gianInSnapshots cho NodeJ bằng quản trị viên Firebase?

In lại Tác giả: IT Lão Cao 更新时间:2023-10-28 22:06:39 31 4
mua khóa gpt4 giày nike

由于有关 Firestore 中时间戳行为即将发生变化的警告,我正在尝试更改我的应用的初始化代码。

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.

不过,我找不到对 firestore“设置”的任何引用。像这样的东西会起作用吗? Typescript 定义说不...

import * as admin from "firebase-admin";

export const adminApp = admin.initializeApp();

const firestore = admin.firestore(adminApp);
firestore.settings({ timestampsInSnapshots: true });

câu trả lời hay nhất

我已将 firebase-admin 升级到 5.13.0,并在 initializeApp() 之后在我的 index.js 中使用以下 node.js 代码,该警告消失了,之后我的代码可以正常运行。

admin.initializeApp();
const settings = {/* your settings... */ timestampsInSnapshots: true};
admin.firestore().settings(settings);

关于node.js - 如何使用 Firebase-admin 为 NodeJs 设置 timestampsInSnapshots 设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50799024/

31 4 0
Cựu chiến binh CNTT
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress