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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

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)

Responses (1)

Write a response