Using a server timestamp with Firestore is a little different:
// Get the `FieldValue` object
var FieldValue = require("firebase-admin").FieldValue;
// Create a document reference
var docRef = db.collection('objects').doc('some-id');
// Update the timestamp field with the value from the server
var updateTimestamp = docRef.update({
timestamp: FieldValue.serverTimestamp()
});
If it does not work, you can edit var FieldValue = require("firebase-admin").FieldValue;withvar FieldValue = require("firebase-admin").firestore.FieldValue;
source
share