import { updateDoc, serverTimestamp } from "firebase/firestore";
const docRef = doc(db, 'objects', 'some-id');
// Update the timestamp field with the value from the server
const updateTimestamp = await updateDoc(docRef, {
timestamp: serverTimestamp()
});
3条答案
按热度按时间c0vxltue1#
文档中已经讨论过了,只需要导入
serverTimestamp
。vd2z7a6w2#
import {serverTimestamp} from 'firebase/firestore';
然后只需将
timestamp: firebase.firestore.FieldValue.serverTimestamp()
更改为timestamp: serverTimestamp()
cs7cruho3#
如果您在其他答案中得到类型错误,可以尝试以下操作: