Files

56 lines
989 B
JavaScript
Raw Permalink Normal View History

2020-02-19 15:55:06 +11:00
// Objection Docs:
// http://vincit.github.io/objection.js/
2025-09-02 21:43:00 +10:00
import { Model } from "objection";
import db from "../db.js";
import accessListModel from "./access_list.js";
import now from "./now_helper.js";
2020-02-19 15:55:06 +11:00
Model.knex(db());
2020-02-19 15:55:06 +11:00
class AccessListAuth extends Model {
2025-09-02 21:43:00 +10:00
$beforeInsert() {
this.created_on = now();
this.modified_on = now();
2020-02-19 15:55:06 +11:00
// Default for meta
2025-09-02 21:43:00 +10:00
if (typeof this.meta === "undefined") {
2020-02-19 15:55:06 +11:00
this.meta = {};
}
}
2025-09-02 21:43:00 +10:00
$beforeUpdate() {
this.modified_on = now();
2020-02-19 15:55:06 +11:00
}
2025-09-02 21:43:00 +10:00
static get name() {
return "AccessListAuth";
2020-02-19 15:55:06 +11:00
}
2025-09-02 21:43:00 +10:00
static get tableName() {
return "access_list_auth";
2020-02-19 15:55:06 +11:00
}
2025-09-02 21:43:00 +10:00
static get jsonAttributes() {
return ["meta"];
2020-02-19 15:55:06 +11:00
}
2025-09-02 21:43:00 +10:00
static get relationMappings() {
2020-02-19 15:55:06 +11:00
return {
access_list: {
2025-09-02 21:43:00 +10:00
relation: Model.HasOneRelation,
modelClass: accessListModel,
join: {
from: "access_list_auth.access_list_id",
to: "access_list.id",
2020-02-19 15:55:06 +11:00
},
2025-09-02 21:43:00 +10:00
modify: (qb) => {
qb.where("access_list.is_deleted", 0);
},
},
2020-02-19 15:55:06 +11:00
};
}
}
2025-09-02 21:43:00 +10:00
export default AccessListAuth;