Firestore: Unsupported field value: a custom Timestamp object after updating firebase version

Discussão em 'Angular' iniciado por MadMac, Fevereiro 19, 2025.

  1. MadMac

    MadMac Guest

    I updated to firebase v11.3.1 from v8.2.5 and I am using the compat mode.

    However my updates no longer work due to using FieldValue.serverTimestamp() for a date field.

    Any suggestions on how to resolve this?

    Error

    FirebaseError: Function DocumentReference.update() called with invalid data. Unsupported field value: a custom Timestamp object (found in field dateModified in document...


    Code

    constructor(private db: AngularFirestore)

    return this.db.collection(this.membersCollectionPath).doc(uid)
    .update({ ...changes, dateModified: getTimestamp() });

    ---
    import { AngularFirestoreDocument } from '@angular/fire/compat/firestore';
    import firebase from 'firebase/compat/app';
    import 'firebase/compat/auth';
    import 'firebase/compat/firestore';

    export function getTimestamp() {
    return firebase.firestore.FieldValue.serverTimestamp();
    }


    I also tried the below with the same error:

    export function getTimestamp() {
    return firebase.firestore.Timestamp.fromDate(new Date());
    }

    Continue reading...

Compartilhe esta Página