我正在尝试添加Timestamp
在有关 Firebase Cloud 功能的 Firestore 文档中。
我曾尝试过firestore.Timestamp.fromDate(new Date())
,但它不起作用。
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const firestore = admin.firestore();
const createdAt = firestore.Timestamp.fromDate(new Date());
console.log(createdAt);
的价值createdAt
应该返回服务器时间戳,但它抛出错误。
而不是这个:
const firestore = admin.firestore();
const createdAt = firestore.Timestamp.fromDate(new Date());
尝试这个:
const firestore = admin.firestore;
const createdAt = firestore.Timestamp.fromDate(new Date());
可能很难发现差异。所以这是解释:
您正在调用对象“admin”的函数“firestore()”,而不是访问具有您正在查找的属性“Timestamp”的对象“admin”的属性“firestore”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)