diff --git a/src/people/dto/create-people.dto.ts b/src/people/dto/create-people.dto.ts index c26bd35e1b55a7a6fd77eaa3b9049e358d7204e5..2dc4098deb5928378ec1f70e3d3641721fe9a49f 100644 --- a/src/people/dto/create-people.dto.ts +++ b/src/people/dto/create-people.dto.ts @@ -1,23 +1,27 @@ -import { IsBoolean, IsString, IsNotEmpty, IsOptional } from 'class-validator'; - -export class CreatePeopleDto { - - @IsString() - @IsNotEmpty() - firstname: string; - - @IsString() - @IsNotEmpty() - lastname: string; - - @IsOptional() - passwordHash: string; - - @IsString() - @IsNotEmpty() - email: string; - - @IsNotEmpty() - role: number; - -} \ No newline at end of file +import { IsBoolean, IsString, IsNotEmpty, IsOptional, IsNumber } from 'class-validator'; + +export class CreatePeopleDto { + + @IsNumber() + @IsNotEmpty() + ine: number; + + @IsString() + @IsNotEmpty() + firstname: string; + + @IsString() + @IsNotEmpty() + lastname: string; + + @IsOptional() + passwordHash: string; + + @IsString() + @IsNotEmpty() + email: string; + + @IsNotEmpty() + role: number; + +} diff --git a/src/people/dto/update-people.dto.ts b/src/people/dto/update-people.dto.ts index 4097f1e2b7647a6f1f8253e6f3690b404d60ab10..71aa9c1c662dde5a0afdb67f08d4d4951ffe88fd 100644 --- a/src/people/dto/update-people.dto.ts +++ b/src/people/dto/update-people.dto.ts @@ -1,23 +1,28 @@ -import { IsOptional, IsString, IsNotEmpty } from 'class-validator'; - -export class UpdatePeopleDto { - @IsString() - @IsOptional() - firstname: string; - - @IsString() - @IsOptional() - lastname: string; - - @IsString() - @IsOptional() - email: string; - - @IsString() - @IsOptional() - passwordHash: string; - - @IsOptional() - role: number; - -} \ No newline at end of file +import { IsOptional, IsString, IsNotEmpty, IsNumber } from 'class-validator'; + +export class UpdatePeopleDto { + + @IsNumber() + @IsNotEmpty() + ine: number; + + @IsString() + @IsOptional() + firstname: string; + + @IsString() + @IsOptional() + lastname: string; + + @IsString() + @IsOptional() + email: string; + + @IsString() + @IsOptional() + passwordHash: string; + + @IsOptional() + role: number; + +} diff --git a/src/people/entities/people.entity.ts b/src/people/entities/people.entity.ts index 7f8bf24a74e9c15f0f14d0e2e20e87fd75b746da..5a2829e199c5e228fa613f4eff243081a18f37f0 100644 --- a/src/people/entities/people.entity.ts +++ b/src/people/entities/people.entity.ts @@ -1,14 +1,15 @@ -import { People } from '../schemas/people.schema'; - -export class PeopleEntity { - _id: string; - firstname: string; - lastname: string; - email: string; - passwordHash: string; - role: number; - - constructor(partial: Partial<People>) { - Object.assign(this, partial); - } -} \ No newline at end of file +import { People } from '../schemas/people.schema'; + +export class PeopleEntity { + _id: string; + ine: number; + firstname: string; + lastname: string; + email: string; + passwordHash: string; + role: number; + + constructor(partial: Partial<People>) { + Object.assign(this, partial); + } +} diff --git a/src/people/schemas/people.schema.ts b/src/people/schemas/people.schema.ts index 09d9a5f8a4178a5f5d2050222b031acf016bb5fa..98f636ec948f9ba5a74f353339f38ded6c32d718 100644 --- a/src/people/schemas/people.schema.ts +++ b/src/people/schemas/people.schema.ts @@ -1,58 +1,63 @@ -import * as mongoose from 'mongoose'; -import { Document } from 'mongoose'; -import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; - -export type PeopleDocument = People & Document; - -@Schema({ - toJSON: { - virtuals: true, - transform: (doc: any, ret: any) => { - delete ret._id; - }, - }, -}) -export class People { - @Prop({ - type: mongoose.Schema.Types.ObjectId, - auto: true, - }) - _id: any; - - @Prop({ - type: String, - required: true, - trim: true, - minlength: 2, - }) firstname: string; - - @Prop({ - type: String, - required: true, - trim: true, - minlength: 2, - }) lastname: string; - - @Prop({ - type: String, - required: true, - trim: true, - minlength: 2, - }) email: string; - - @Prop({ - type: String, - trim: true, - minlength: 2, - }) passwordHash: string; - - @Prop({ - type: Number, - required: true, - }) role: number; - -} - -export const PeopleSchema = SchemaFactory.createForClass(People); - -PeopleSchema.index({}); \ No newline at end of file +import * as mongoose from 'mongoose'; +import { Document } from 'mongoose'; +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; + +export type PeopleDocument = People & Document; + +@Schema({ + toJSON: { + virtuals: true, + transform: (doc: any, ret: any) => { + delete ret._id; + }, + }, +}) +export class People { + @Prop({ + type: mongoose.Schema.Types.ObjectId, + auto: true, + }) + _id: any; + + @Prop({ + type: Number, + required: true, + }) ine: number; + + @Prop({ + type: String, + required: true, + trim: true, + minlength: 2, + }) firstname: string; + + @Prop({ + type: String, + required: true, + trim: true, + minlength: 2, + }) lastname: string; + + @Prop({ + type: String, + required: true, + trim: true, + minlength: 2, + }) email: string; + + @Prop({ + type: String, + trim: true, + minlength: 2, + }) passwordHash: string; + + @Prop({ + type: Number, + required: true, + }) role: number; + +} + +export const PeopleSchema = SchemaFactory.createForClass(People); + +PeopleSchema.index({});