Spaces:
Paused
Paused
File size: 732 Bytes
abc1805 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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);
|