async addNewUser(id: string, email: string) {
await this.afs.doc<MemberProfileModel>(FirestoreDbConstant.MEMBER_PROFILES + `/${id}`).set({
email,
registeredDate: firebase.firestore.FieldValue.serverTimestamp(),
});
}
This approach is functioning well.
export interface MemberProfileModel {
email: string;
registeredDate?: firebase.firestore.FieldValue;
}
However, why am I encountering issues when trying to use Timestamp
as follows?
import { Timestamp } from '@firebase/firestore-types';
export interface MemberProfileModel {
email: string;
registeredDate?: Timestamp;
}
The above code snippet results in the following error message:
(property) MemberProfileModel.registeredDate?: Timestamp Type 'FieldValue' is missing properties such as seconds, nanoseconds, toDate, toMillists(2739) user-profile.model.ts(11, 5): The expected type is derived from property 'registeredDate' declared in type 'MemberProfileModel'
The main issue here is that I need to utilize toDate()
in the template, which does not work with
registeredDate?: firebase.firestore.FieldValue;
<p>{{memberEvent.joiningDatetime.toDate() | amDateFormat: 'MMM DD'}}</p>