access_list_client.js 997 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Objection Docs:
  2. // http://vincit.github.io/objection.js/
  3. import { Model } from "objection";
  4. import db from "../db.js";
  5. import accessListModel from "./access_list.js";
  6. import now from "./now_helper.js";
  7. Model.knex(db);
  8. class AccessListClient extends Model {
  9. $beforeInsert() {
  10. this.created_on = now();
  11. this.modified_on = now();
  12. // Default for meta
  13. if (typeof this.meta === "undefined") {
  14. this.meta = {};
  15. }
  16. }
  17. $beforeUpdate() {
  18. this.modified_on = now();
  19. }
  20. static get name() {
  21. return "AccessListClient";
  22. }
  23. static get tableName() {
  24. return "access_list_client";
  25. }
  26. static get jsonAttributes() {
  27. return ["meta"];
  28. }
  29. static get relationMappings() {
  30. return {
  31. access_list: {
  32. relation: Model.HasOneRelation,
  33. modelClass: accessListModel,
  34. join: {
  35. from: "access_list_client.access_list_id",
  36. to: "access_list.id",
  37. },
  38. modify: (qb) => {
  39. qb.where("access_list.is_deleted", 0);
  40. },
  41. },
  42. };
  43. }
  44. }
  45. export default AccessListClient;