Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

297
Vistas
How to use firebase.firestore.FieldValue.serverTimestamp() now?

I am following a tutorial and firebase.firestore.FieldValue.serverTimestamp() is used in the code to set timestamp prop as the server timestamp.

import firebase from "firebase";
const someFunction = () => {
    addDoc(collection(db, `rooms/${roomId}/messages`), {
      message: input,
      name: user.displayName,
      timestamp: firebase.firestore.FieldValue.serverTimestamp(),
    }).then((res) => getMessagesData());
  };

But I get this error.

Module not found: Can't resolve 'firebase' in ...

I suppose firebase had some kind of update that we don't import it with import firebase from "firebase"; anymore? What should I do to use the servertimestamp()?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For an up to date sample, see the documentation on adding a server-side timestamp, which contains this snippet

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()
});

The documentation has side-by-side examples for both the new v9 modular syntax and the older syntax that you're likely to find in many third-party tutorials, so you can look up how to translate the code to the newer syntax. The upgrade guide is a good way to get started with that too.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda