Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

495
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!