firebase-admin-node
firebase-admin-node copied to clipboard
[Firestore] Version 12, issue with queries and withConverter()
We expect to get a snapshot with the right type, but instead, we get unknown.
Downgrading to 11.11.0 fixes the issue
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
+1
I have been following this pattern:
// converter from https://stackoverflow.com/questions/74456704/how-to-type-usefirestore-using-typescript-interfaces
export const firebaseConverter = <T>() => ({
toFirestore: (data: PartialWithFieldValue<T>) => data,
fromFirestore: (snap: QueryDocumentSnapshot) => snap.data() as T,
});
const userDocQuery = admin.firestore().collection('users').doc(userId).withConverter(firebaseConverter<User>());
But this does not work with Version 12.