20 lines
501 B
TypeScript
20 lines
501 B
TypeScript
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
|
|
@Schema({ collection: 'users', timestamps: true, versionKey: false })
|
|
export class UserDocument {
|
|
@Prop({ type: String, required: true })
|
|
_id!: string;
|
|
|
|
@Prop({ required: true })
|
|
name!: string;
|
|
|
|
@Prop({ required: true, index: true })
|
|
email!: string;
|
|
|
|
@Prop({ default: true })
|
|
isActive!: boolean;
|
|
}
|
|
|
|
export const UserSchema = SchemaFactory.createForClass(UserDocument);
|
|
UserSchema.index({ name: 'text', email: 'text' });
|