33 lines
818 B
TypeScript
33 lines
818 B
TypeScript
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<IPermission>({
|
|
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;
|