import DB from "../database.js";
import { ModelDataBase } from "@hibas123/safe_mongo/lib/model.js";
import { ObjectId } from "mongodb";

export interface IClientCode extends ModelDataBase {
   user: ObjectId;
   code: string;
   client: ObjectId;
   permissions: ObjectId[];
   validTill: Date;
}

const ClientCode = DB.addModel<IClientCode>({
   name: "client_code",
   versions: [
      {
         migration: () => { },
         schema: {
            user: { type: ObjectId },
            code: { type: String },
            client: { type: ObjectId },
            permissions: { type: Array },
            validTill: { type: Date },
         },
      },
   ],
});
export default ClientCode;
