OpenAuth_server/src/models/permissions.ts

38 lines
908 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",
2020-08-07 14:16:39 +00:00
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" },
},
},
],
});
2018-11-06 19:48:50 +00:00
2020-03-17 15:27:57 +00:00
export default Permission;