I have upgraded my Firebase v8 project to v9. The web application now uses the modular SDK with the new functional API for Firestore.
In this project I use Firebase Functions. There I have upgraded to firebase-admin 11.0.0. But it seams it does not provide the new functional API for Firestore.
const { initializeApp } = require('firebase-admin/app');
const app = initializeApp();
import { getFirestore } from "firebase/firestore";
const db = getFirestore(app);
This throws:
TypeError: Cannot read properties of undefined (reading 'getProvider')
at Object._getProvider (/p/happygast/node_modules/@firebase/app/src/internal.ts:110:6)
at Object.getFirestore (/p/happygast/node_modules/@firebase/firestore/src/api/database.ts:185:10)
Now I am not sure if I am doing something wrong? Or is there no functional Firestore API for Cloud Functions?
In essence: Is firebase-admin/app compatible with firebase/firestore? Or: How do I initialize and use firebase/firestore in Firebase Cloud Functions?