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

499
Vistas
Angular / Firebase / Firestore - How to import firebase to use `serverTimestamp`

Angular - v13.1 Firebase - ^9.6.2

In the old version of firebase, it was possible to import firebase into an Angular component to utilise the serverTimestamp property:

import firebase from 'firebase/app';
import 'firebase/firestore';
---
this.afs.doc(`${db_path}`).set({
 dateCreated: firebase.firestore.FieldValue.serverTimestamp(),
)};

However, since being on the new version, this approach no longer seems to work. Looking through the documentation, I haven't (...yet) found anything that suggests an alternate way to import firebase into a component to use this value.

Is there a better approach to utilise the timestamp type to set as a value?

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

0

Ok, so the following seems to work. Not sure if it's 100% correct.

Model/Interface

import { FieldValue, serverTimestamp } from "firebase/firestore";

export interface Folder extends Base {
  created: typeof serverTimestamp | FieldValue | Date;
}

Component

import { serverTimestamp } from "firebase/firestore";

---

new(){
  this.afs.collection<Model>(`path`).add({
      created: serverTimestamp()
  })
}
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