import mongoose from "mongoose"; const ROLES = ["user", "admin"]; const UserSchema = new mongoose.Schema( { username: { type: String, required: true, unique: true, }, password: { type: String, required: true, }, points: { type: Number, default: 0 }, role: { type: String, enum: ROLES, default: "user" }, securityQuestion: { type: String, }, securityAnswer: { type: String }, lastLoginAt: { type: Date }, }, { timestamps: true } ); export default mongoose.models.User || mongoose.model("User", UserSchema);