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

388
Views
TypeError: db.collection is not a function Firestore

TypeError: db.collection is not a function Firestore

I was presented this error in an attempt to import Firestore from the Firebase Admin SDK. Can't find anything that helped, or if I imported it incorrectly

Code; index.js (main file)

var admin = require("firebase-admin");
var serviceAccount = require("./firebase/key.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

var db = admin.firestore()

Code; validate.js (import)

var db = require('../../../index')
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you just imported the Admin SDK, the syntax has changed to be modular. Check the latest documentation on initializing Firestore which shows how to initialize Firestore with the new getFirestore top-level function:

const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestore');
...
const db = getFirestore();
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!