Skip to content

toFirestore inside globalFirestoreOptions.converter is never called #1499

Discussion options

You must be logged in to vote

It works if I use .withConverter instead.
Exemple:

const addDefaultFields = {
    toFirestore(docData: DocumentData): DocumentData {
        console.log('test 1');
        return {
            created_at: serverTimestamp(),
            ...docData,
        }
    },
    fromFirestore(snapshot: QueryDocumentSnapshot, options: SnapshotOptions): DocumentData {
        console.log('test 2');
        const data = firestoreDefaultConverter.fromFirestore(snapshot)!;
        return data;
    },
};

...

async function addProject(option: Project) {
    const project = await addDoc(collection(db, 'projects').withConverter(addDefaultFields), {
        name: option.name,
        user: user.value!.uid,

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@posva
Comment options

@mrleblanc101
Comment options

@mrleblanc101
Comment options

@mrleblanc101
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1497 on February 25, 2024 10:28.