import DB from "../database"; import { ModelDataBase } from "@hibas123/safe_mongo/lib/model"; import { ObjectId } from "mongodb"; export interface IPermission extends ModelDataBase { name: string; description: string; client: ObjectId; grant_type: "user" | "client"; } const Permission = DB.addModel({ name: "permission", versions: [ { migration: () => { }, schema: { name: { type: String }, description: { type: String }, client: { type: ObjectId }, }, }, { migration: (old) => { old.grant_type = "user"; }, schema: { name: { type: String }, description: { type: String }, client: { type: ObjectId }, grant_type: { type: String, default: "user" }, }, }, ], }); export default Permission;