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

213
Views
How to delete a field in a collection with firebase-admin?

I have a collection like this into firebase realtime database:

enter image description here

I need to delete the first element (the one that finishes with Wt6J) from server side using firebase-admin.

I have this simple code:

const deleteNotification = () => {
  const key1 = 'FhN6Ntw8gyPLwJYVzcHy0E8Wq5z2';
  const key2 = '-MzGhZ2psGLivIfTWt6J';
  const notsRef = db.ref(`notifications/${key1}/${key2}`);
  notsRef.remove();
};

This doesn't work. What method should I use to delete a specific field? How do you think I can do it?

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

0

I would think to use await in a try catch block. Await starts another thread which returns once it has completed. As people said above - your cloud function is likely being killed before the remove actually happens.

const deleteNotification = async () => {
  try{
    const key1 = 'FhN6Ntw8gyPLwJYVzcHy0E8Wq5z2';
    const key2 = '-MzGhZ2psGLivIfTWt6J';
    const notsRef = db.ref(`notifications/${key1}/${key2}`);
    await notsRef.remove();
  } catch( err ) {
    console.log( 'failed to remove record.' );
    console.log( err );
  }
  console.log( 'removed record successfully.' );
};
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!