-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathuser.model.ts
37 lines (33 loc) · 1.04 KB
/
user.model.ts
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
32
33
34
35
36
37
import { Schema, models, model, Document } from "mongoose";
export interface IUser extends Document {
clerkId: string;
name: string;
username: string;
email: string;
password?: string;
bio?: string;
picture: string;
location?: string;
portfolioWebsite?: string;
reputation?: number;
saved: Schema.Types.ObjectId[];
onboarded: boolean;
joinedAt: Date;
}
const UserSchema = new Schema({
clerkId: { type: String, required: true },
name: { type: String, required: true },
username: { type: String, required: true, unique: true },
email: { type: String, required: true, unique: true },
password: { type: String },
bio: { type: String },
picture: { type: String, required: true },
location: { type: String },
portfolioWebsite: { type: String },
reputation: { type: Number, default: 0 },
saved: [{ type: Schema.Types.ObjectId, ref: "Question" }],
onboarded: { type: Boolean, default: false },
joinedAt: { type: Date, default: Date.now },
});
const User = models.User || model("User", UserSchema);
export default User;