forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
105
src/users/entities/schema/expert.schema.ts
Normal file
105
src/users/entities/schema/expert.schema.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import { Degrees } from "src/Types&Enums/degrees.enum";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { UserType } from "src/Types&Enums/userType.enum";
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class RequestStats {
|
||||
@Prop({ default: 0 })
|
||||
totalHandled: number;
|
||||
|
||||
@Prop({ default: 0 })
|
||||
totalChecked: number;
|
||||
}
|
||||
|
||||
const RequestStatsSchema = SchemaFactory.createForClass(RequestStats);
|
||||
|
||||
@Schema({ collection: "expert", versionKey: false, timestamps: true })
|
||||
export class ExpertModel {
|
||||
@Prop({})
|
||||
firstName: string;
|
||||
|
||||
@Prop({})
|
||||
role: RoleEnum;
|
||||
|
||||
@Prop({})
|
||||
userType: UserType;
|
||||
|
||||
@Prop({})
|
||||
lastName: string;
|
||||
|
||||
@Prop({ unique: true })
|
||||
nationalCode: string;
|
||||
|
||||
@Prop({ type: "string", unique: true })
|
||||
email: string;
|
||||
|
||||
@Prop({})
|
||||
password: string;
|
||||
|
||||
@Prop({})
|
||||
sheba: string;
|
||||
|
||||
@Prop({})
|
||||
phone: string;
|
||||
|
||||
@Prop({})
|
||||
mobile: string;
|
||||
|
||||
@Prop({})
|
||||
city: string;
|
||||
|
||||
@Prop({})
|
||||
state: string;
|
||||
|
||||
@Prop({})
|
||||
address: string;
|
||||
|
||||
@Prop({ type: String })
|
||||
expDegree: Degrees;
|
||||
|
||||
@Prop({})
|
||||
insuActivityTime?: number;
|
||||
|
||||
@Prop({})
|
||||
insuActivityCo?: string;
|
||||
|
||||
@Prop({})
|
||||
policeActivityTime?: number;
|
||||
|
||||
@Prop({})
|
||||
policeActivityKind?: string;
|
||||
|
||||
@Prop({})
|
||||
policeServicePlace?: string;
|
||||
|
||||
@Prop({})
|
||||
clientKey?: string;
|
||||
|
||||
@Prop({ type: "string" })
|
||||
otp: string;
|
||||
|
||||
@Prop({ type: RequestStatsSchema, default: () => ({}) })
|
||||
requestStats: RequestStats;
|
||||
|
||||
@Prop({
|
||||
type: [{ type: String }],
|
||||
default: [],
|
||||
validate: {
|
||||
validator: (arr: any[]) => arr.every((val) => typeof val === "string"),
|
||||
message: "All countedRequests must be strings",
|
||||
},
|
||||
})
|
||||
countedRequests?: string[];
|
||||
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export const ExpertDbSchema = SchemaFactory.createForClass(ExpertModel);
|
||||
|
||||
ExpertDbSchema.pre("save", function (next) {
|
||||
if (!this.requestStats) {
|
||||
this.requestStats = { totalChecked: 0, totalHandled: 0 };
|
||||
}
|
||||
next();
|
||||
});
|
||||
Reference in New Issue
Block a user