const mongoose = require("mongoose");

const userSchema = new mongoose.Schema(
    {
        username: {
            type: String,
            required: true,
        },
        password: {
            type: String,
            required: true,
        },
        email: {
            type: String,
            required: true,
        },
        fullname: {
            type: String,
            required: true,
        },
        role: {
            type: String,
            required: false,
            enum: ["ADMIN", "CUSTOMER"],
            default: "CUSTOMER",
        },
        archived: {
            type: Boolean,
            required: false,
            default: false,
        },
    },
    { timestamps: true }
);

const userModel = mongoose.model("User", userSchema, "user");

module.exports = {
    Schema: userSchema,
    Model: userModel,
};
