最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - Firestore: Unsupported field value: a custom Timestamp object after updating firebase version - Stack Overflow

programmeradmin3浏览0评论

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());
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论