I'm using the Firebase Admin SDK in my Express + Typescript server. I'm trying to use Firestore's method withConverter() However, I get the error "Cannot find namespace 'FirebaseFirestore'.ts(2503)". How can I deal with this?
admin.initializeApp({ credential: admin.credential.cert(serviceAccount) }); const firestore = admin.firestore(); interface BlogpostColletion { text: String, title: String, } interface UsersCollection { blogposts: BlogpostColletion } const converter = { toFirestore: (data: UsersCollection) => data, // PROBLEM HERE "Cannot find namespace 'FirebaseFirestore'.ts(2503)" fromFirestore: (snap: FirebaseFirestore.QueryDocumentSnapshot) => snap.data() as UsersCollection }
You can import QueryDocumentSnapshot
from Admin SDK like this:
import * as admin from "firebase-admin"
fromFirestore: (snap: admin.firestore.QueryDocumentSnapshot)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.