Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export interface UserDocument {
- _id: Types.ObjectId;
- phoneNumber: string;
- username: string;
- password: string;
- family: string;
- name: string;
- gender: GenderEnum;
- createdAt?: Date | any;
- updatedAt?: Date | any;
- }
- export interface CommentDocument {
- _id?: string;
- owner?: string | ObjectId | User;
- title?: string;
- text: string;
- isVerified?: boolean;
- createdAt?: Date;
- updatedAt?: Date;
- }
- function isUser(user: any): user is User {
- return 'phoneNumber' in user;
- }
- export class CommentOutputDto {
- constructor(data: CommentDocument) {
- this._id = data._id?.toString();
- if (isUser(data.owner)) {
- this.owner = {
- _id: data.owner._id.toString(),
- name: data.owner.name,
- lastname: data.owner.lastname,
- };
- }
- /* ... */
- }
- _id: string;
- owner?: Partial<User>;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement