123456789101112131415161718192021222324252627 |
- 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);
|