forked from Yara724/api
Added expert field mirror flow
This commit is contained in:
3
src/features/user/schemas/index.ts
Normal file
3
src/features/user/schemas/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { OtpSchema, Otp, OtpDocument } from "./otp.schema";
|
||||
export { ProfileSchema, Profile, ProfileDocument } from "./profile.schema";
|
||||
export { UserSchema, User, UserDocument } from "./user.schema";
|
||||
24
src/features/user/schemas/otp.schema.ts
Normal file
24
src/features/user/schemas/otp.schema.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import { HydratedDocument } from "mongoose";
|
||||
|
||||
export type OtpDocument = HydratedDocument<Otp>;
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Otp {
|
||||
@Prop()
|
||||
hash: string;
|
||||
|
||||
@Prop()
|
||||
salt: string;
|
||||
|
||||
@Prop()
|
||||
expiresAt: Date;
|
||||
|
||||
@Prop({ default: 0 })
|
||||
attempts: number;
|
||||
|
||||
@Prop({ default: Date.now })
|
||||
generatedAt: Date;
|
||||
}
|
||||
|
||||
export const OtpSchema = SchemaFactory.createForClass(Otp);
|
||||
18
src/features/user/schemas/profile.schema.ts
Normal file
18
src/features/user/schemas/profile.schema.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import { HydratedDocument } from "mongoose";
|
||||
|
||||
export type ProfileDocument = HydratedDocument<Profile>;
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Profile {
|
||||
@Prop()
|
||||
firstName?: string;
|
||||
|
||||
@Prop()
|
||||
lastName?: string;
|
||||
|
||||
@Prop()
|
||||
birthDate?: Date;
|
||||
}
|
||||
|
||||
export const ProfileSchema = SchemaFactory.createForClass(Profile);
|
||||
22
src/features/user/schemas/user.schema.ts
Normal file
22
src/features/user/schemas/user.schema.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import { HydratedDocument, Types } from "mongoose";
|
||||
import { Otp, OtpSchema, Profile, ProfileSchema } from "./index";
|
||||
|
||||
export type UserDocument = HydratedDocument<User>;
|
||||
|
||||
@Schema({
|
||||
id: true,
|
||||
timestamps: true,
|
||||
})
|
||||
export class User {
|
||||
@Prop({ required: true, unique: true, index: true })
|
||||
cellphoneNumber: string;
|
||||
|
||||
@Prop({ type: OtpSchema })
|
||||
otp?: Otp;
|
||||
|
||||
@Prop({ type: ProfileSchema })
|
||||
profile?: Profile;
|
||||
}
|
||||
|
||||
export const UserSchema = SchemaFactory.createForClass(User);
|
||||
Reference in New Issue
Block a user