firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

[Firestore] Version 12, issue with queries and withConverter()

Open Daavidaviid opened this issue 1 year ago • 3 comments

We expect to get a snapshot with the right type, but instead, we get unknown.

Downgrading to 11.11.0 fixes the issue

Daavidaviid avatar Jan 30 '24 02:01 Daavidaviid

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Jan 30 '24 02:01 google-oss-bot

+1

AnderzL7 avatar Mar 27 '24 12:03 AnderzL7

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.

jfbloom22 avatar Apr 10 '24 13:04 jfbloom22