import mongoose, { Document, Model, Schema, model } from "mongoose";

export interface ICompany {
    id?: string;
    name: string;
    ownerId: string;
    automaticNotifications?: boolean;
}

export interface ICompanyDocument extends Omit<ICompany, "id">, Document {}

export class Companies {
    schema: Schema;
    companyList: Model<ICompanyDocument>;

    constructor() {
        this.schema = new Schema({
            name: { type: String, required: true, unique: true },
            ownerId: { type: Schema.Types.ObjectId, required: true, ref: "User" },
            automaticNotifications: { type: Boolean, required: false },
        });

        this.companyList = model<ICompanyDocument>("Company", this.schema);
    }
}
