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

export interface IGrant extends ModelDataBase {
   user: ObjectId;
   client: ObjectId;
   permissions: ObjectId[];
}

const Grant = DB.addModel<IGrant>({
   name: "grant",
   versions: [
      {
         migration: () => { },
         schema: {
            user: { type: ObjectId },
            client: { type: ObjectId },
            permissions: { type: ObjectId, array: true },
         },
      },
   ],
});

export default Grant;
