Spaces:
Paused
Paused
| import mongoose, { Schema, Document } from "mongoose"; | |
| export interface IUser extends Document { | |
| email: string; | |
| password?: string; | |
| image?: string; | |
| twoFactorSecret?: string; | |
| isTwoFactorEnabled: boolean; | |
| createdAt: Date; | |
| } | |
| const UserSchema: Schema = new Schema({ | |
| email: { type: String, required: true, unique: true }, | |
| password: { type: String, required: false }, // Optional for OAuth, but we are using Credentials | |
| image: { type: String }, | |
| twoFactorSecret: { type: String }, | |
| isTwoFactorEnabled: { type: Boolean, default: false }, | |
| createdAt: { type: Date, default: Date.now }, | |
| }); | |
| export default mongoose.models.User || mongoose.model<IUser>("User", UserSchema); | |