Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nestjs mongoose schema

// user.schema.ts
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

export type UserDocument = User & Document;

@Schema()
export class User {
  @Prop({ type: String, unique: true })
  username: string;
  
  @Prop({ type: String })
  password: string;
}

export const UserSchema = SchemaFactory.createForClass(User);
 
PREVIOUS NEXT
Tagged: #nestjs #mongoose #schema
ADD COMMENT
Topic
Name
2+6 =