-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathuser.model.ts
More file actions
31 lines (27 loc) · 798 Bytes
/
user.model.ts
File metadata and controls
31 lines (27 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { model, models, Schema, Document,HydratedDocument } from "mongoose";
export interface IUser {
name: string;
username: string;
email: string;
bio?: string;
image?: string;
location?: string;
portfolio?: string;
reputation?: number;
}
export type IUserDoc = HydratedDocument<IUser>;
const UserSchema = new Schema<IUser>(
{
name: { type: String, required: true },
username: { type: String, required: true, unique: true },
email: { type: String, required: true, unique: true },
bio: { type: String },
image: { type: String },
location: { type: String },
portfolio: { type: String },
reputation: { type: Number, default: 0 },
},
{ timestamps: true }
);
const User = models?.User || model<IUser>("User", UserSchema);
export default User;