Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

441
Vistas
access firestore from firebase-functions using web version 9 interface (modular)

I have to access a firestore database within firebase functions. I use the following code to get a firestore instance:

import { initializeApp } from "firebase-admin/app"
initializeApp();

import { getFirestore } from 'firebase-admin/firestore'
const db = getFirestore();

This instance can be used to access the database

db.collection('test').add( { anything: 123 } )
db.collection('test').doc('test123').set( { afield: 1234 } )
db.collection('test').doc('test123').get()

According to https://firebase.google.com/docs/firestore/query-data/queries#web-version-8 this is "Web version 8 (namespaced)" interface for accessing firestore databases.

How can I use the "Web version 9 (modular)" interface? The version 9 example from the same page:

import { collection, doc, setDoc } from "firebase/firestore"; 
const citiesRef = collection(db, "cities");

results in the following error:

FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore

Is there a way to query firestore with admin privileges using modular interface?

Thank You!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The Admin SDK does not use functional syntax totally yet. The Web version 8/9 are client SDK. Refer to NodeJS tab of the documentation when using Firebase Admin SDK.

Also you are importing collection() from Firebase client SDK but it seems the db is initialized using getFirestore() from Firebase SDK that might not work properly.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda