Created
October 22, 2024 01:50
-
-
Save sidneyroberto/746aaa5e248bdb9d42212b92f0c98ae1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const contactConverter: FirestoreDataConverter<Contact, DocumentData> = { | |
toFirestore: (contact: Contact): DocumentData => { | |
const cleanContact = Object.entries(work) | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
.filter(([_, value]) => value !== undefined) | |
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}); | |
return cleanContact; | |
}, | |
fromFirestore: ( | |
snapshot: QueryDocumentSnapshot, | |
options: SnapshotOptions | |
) => { | |
const data = snapshot.data(options); | |
return new Contact(data); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment