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

130
Views
How do I make sure to insert the same date when executing batch operations in firebase?

I have to perform batch query in firebase. This query touches two different collections and inserts date value in each of them. I use firebase.firestore.FieldValue.serverTimestamp(). Part of my query:

async function batchQuery() {
    const batch = db.batch();

    const firstCollectionRef = db
      .collection("firstCollection")
      .doc(id);
    batch.set(firstCollectionRef, {
      someData: data,
      date: firebase.firestore.FieldValue.serverTimestamp(),
    });

    
    const secondCollectionRef = db.collection("secondCollection").doc(id);
    batch.set(
      secondCollectionRef,
      {
        someData: data,
        date: firebase.firestore.FieldValue.serverTimestamp(),
      },
      { merge: true }
    );

    await batch.commit();
  }

How do I make sure that date field in both collections has the same value?

about 4 years ago · Juan Pablo Isaza
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!