All checks were successful
Build And Deploy Main / build-and-deploy (push) Successful in 34s
38 lines
813 B
JavaScript
38 lines
813 B
JavaScript
module.exports = (mongoose) => {
|
|
const schema = mongoose.Schema(
|
|
{
|
|
external_user_id: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
allow_site: {
|
|
type: Number,
|
|
required: true
|
|
},
|
|
username: String,
|
|
name: String,
|
|
title: String,
|
|
email: String,
|
|
permissions: [
|
|
{
|
|
type: String
|
|
}
|
|
],
|
|
create_by: String,
|
|
edit_by: String
|
|
},
|
|
{ collection: "ext_usr_perm", timestamps: true }
|
|
);
|
|
|
|
schema.method("toJSON", function () {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
|
|
schema.index({ external_user_id: 1, allow_site: 1 }, { unique: true });
|
|
|
|
const ExtUserPermission = mongoose.model("ext_usr_perm", schema);
|
|
return ExtUserPermission;
|
|
};
|