import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { v4 as uuidv4 } from 'uuid'; import { BaseEntity } from 'src/_core/_base.entity'; import * as mongoosePaginate from 'mongoose-paginate-v2'; import { Document } from 'mongoose'; @Schema({ _id: false, id: false }) // Disable _id and virtual id export class Participant extends BaseEntity { @Prop({ type: String, default: () => uuidv4(), required: true, immutable: true, }) userId: string; @Prop({ type: String, enum: ['moderator', 'tester', 'admin', 'user'], default: 'user', required: true, }) role: 'moderator' | 'tester' | 'admin' | 'user'; @Prop({ type: String, required: true, }) displayName: string; } export type ParticipantDocument = Participant & Document; export const ParticipantSchema = SchemaFactory.createForClass(Participant); ParticipantSchema.plugin(mongoosePaginate); ParticipantSchema.set('toJSON', { transform: (doc: ParticipantDocument, ret: Participant & { _id?: any }) => { delete ret._id; return ret; }, });