Acid Coder
Oct 16, 2021

--

unfortunately this is not flexible enough to handle field value as field value output is different from input

especially server timestamp, also apply to number and array where they can accept field value

we still need better wrapper

const converter = {

toFirestore: (data: { createdAt: Firestore.FieldValue }) => data, // server time stamp

fromFirestore: (snap: FirebaseFirestore.QueryDocumentSnapshot) =>

snap.data() as {

createdAt: Firestore.Timestamp // timestamp object

},

}

firestore().collection('users').withConverter(converter) // type error

--

--

Acid Coder
Acid Coder

Written by Acid Coder

Typescript Zombie. Youtube Pikachu On Acid. (Unrelated to programming but by watching it you become a good developer overnight)