-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathaccount.model.ts
More file actions
27 lines (23 loc) · 768 Bytes
/
account.model.ts
File metadata and controls
27 lines (23 loc) · 768 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
import { model, models, Schema, Types, Document , HydratedDocument} from "mongoose";
export interface IAccount {
userId: Types.ObjectId;
name: string;
image?: string;
password?: string;
provider: string;
providerAccountId: string;
}
export type IAccountDoc = HydratedDocument<IAccount>;
const AccountSchema = new Schema<IAccount>(
{
userId: { type: Schema.Types.ObjectId, ref: "User", required: true },
name: { type: String, required: true },
image: { type: String },
password: { type: String },
provider: { type: String, required: true },
providerAccountId: { type: String, required: true },
},
{ timestamps: true }
);
const Account = models?.Account || model<IAccount>("Account", AccountSchema);
export default Account;