OpenAuth_server/src/models/permissions.ts

33 lines
818 B
TypeScript
Raw Normal View History

2018-11-06 19:48:50 +00:00
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;
2020-03-17 15:27:57 +00:00
grant_type: "user" | "client";
2018-11-06 19:48:50 +00:00
}
const Permission = DB.addModel<IPermission>({
name: "permission",
versions: [{
migration: () => { },
schema: {
name: { type: String },
description: { type: String },
client: { type: ObjectID }
}
2020-03-17 15:27:57 +00:00
}, {
migration: (old) => { old.grant_type = "user" },
schema: {
name: { type: String },
description: { type: String },
client: { type: ObjectID },
grant_type: { type: String, default: "user" }
}
2018-11-06 19:48:50 +00:00
}]
})
2020-03-17 15:27:57 +00:00
export default Permission;