2025-08-22 14:22:43 +08:00
|
|
|
import { Schema, model, Document } from 'mongoose';
|
|
|
|
|
|
|
|
export interface IUser extends Document {
|
|
|
|
email: string;
|
|
|
|
passwordHash: string;
|
2025-08-22 17:14:38 +08:00
|
|
|
name?: string;
|
2025-08-22 14:22:43 +08:00
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
}
|
|
|
|
|
|
|
|
const UserSchema = new Schema<IUser>({
|
|
|
|
email: { type: String, required: true, unique: true, index: true },
|
|
|
|
passwordHash: { type: String, required: true }
|
2025-08-22 17:14:38 +08:00
|
|
|
, name: { type: String }
|
2025-08-22 14:22:43 +08:00
|
|
|
}, { timestamps: true });
|
|
|
|
|
|
|
|
export const User = model<IUser>('User', UserSchema);
|