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

222
Views
Why doesn't my Cloud Function trigger receive the ID on create?

I am following the code in this wiki page: https://firebase.google.com/docs/functions/firestore-events and have deployed the following code to a cloud function:

const { initializeApp } = require('firebase-admin/app');
const { getFirestore  } = require('firebase-admin/firestore');
const uuid = require('uuid');
const functions = require('firebase-functions');

initializeApp()
const db = getFirestore();

exports.newDoc = functions.firestore
   .document('doc/{docId}')
   .onCreate((snap, context) => {
       console.log(context.params.docId);
       console.log(snap.data());
       db.collection('monitor').doc(uuid.v1()).set(snap.data()).then(_=>console.log('saved'));
});

When I add a doc to my 'doc' collection via the Firestore console it adds a document to my 'monitor' collection. When I check for the 'context.params.docId' log however there is a line there but it is completely empty (no contents at all). What am I missing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I managed to find my id by logging the entire context :) It is actually in the params object but as context.params.pushId

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!