I'm sure anyone who already knows will think this is an obvious question but I've already spent a lot of time searching the docs for this.
I would think you do something like this, but this doesn't work:
import * as firebase from 'firebase/app';
export interface ChatMessage {
message: string;
dateSent: firebase.firestore.serverTimestamp();
}
Also, I've seen this in some places, but it doesn't work for me either...
firebase.firestore.FieldValue.serverTimestamp();
I just get Namespace 'firebase.firestore' has no exported member 'FieldValue'.
Figured out what I was doing wrong! It should be this...
import * as firebase from 'firebase/app';
export interface ChatMessage {
message: string;
dateSent: firebase.firestore.FieldValue;
}
OR
import { firestore } from 'firebase/app';
export interface ChatMessage {
message: string;
dateSent: firestore.FieldValue;
}
Then when I go to make a chat message, it will let me do this:
<ChatRoom>{
newCount: newTotal,
lastMessageDate: firebase.firestore.FieldValue.serverTimestamp();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With