access_list_auth.js 986 B

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