How to get serverTimestamp via Angularfire or firebase

Discussão em 'Angular' iniciado por Laker, Setembro 11, 2024.

  1. Laker

    Laker Guest

    I can't find a way to get serverTimestamp from firestore. Either with firestore itself, or with angularfire.

    I found a lot of github issues with solutions, which doesn't work. I guess that's because of a different version?

    "@firebase/app": "^0.1.10",
    "angularfire2": "^5.0.0-rc.6.0",
    "firebase": "^4.13.1",


    Code alternatives I've tried:

    import * as firebase from 'firebase';
    firebase.firestore.FieldValue.serverTimestamp();


    ERROR TypeError: Cannot read property 'FieldValue' of undefined
    ​

    import * as firebase from 'firebase';
    firebase.database.ServerValue.TIMESTAMP;


    ERROR TypeError: Cannot read property 'ServerValue' of undefined
    ​

    constructor( private afs: AngularFirestore ) { }
    this.afs.firestore.FieldValue.serverTimestamp();


    Property 'FieldValue' does not exist on type 'FirebaseFirestore'.
    ​

    Continue reading...

Compartilhe esta Página