以下代码突然返回ServerTimestampTransform而不是实际的服务器时间戳
admin.firestore.FieldValue.serverTimestamp()
我正在使用Firebase-admin的最新版本8.6.0 https://www.npmjs.com/package/firebase-admin
关于此的任何想法
-Jani
答案 0 :(得分:1)
这是示例在github代码中概述的内容
/**
* Returns a sentinel used with set(), create() or update()
to include a
* server-generated timestamp in the written data.
*
* @return {FieldValue} The FieldValue sentinel for use in
a call to set(),
* create() or update().
*
* @example
* let documentRef = firestore.doc('col/doc');
*
* documentRef.set({
* time: Firestore.FieldValue.serverTimestamp()
* }).then(() => {
* return documentRef.get();
* }).then(doc => {
* console.log(`Server time set to ${doc.get('time')}`);
* });
*/
static serverTimestamp(): FieldValue {
return ServerTimestampTransform.SERVER_TIMESTAMP_SENTINEL;
}