settings.js 654 B

12345678910111213141516171819202122232425262728293031
  1. const Model = require('objection').Model
  2. /**
  3. * Settings model
  4. */
  5. module.exports = class User extends Model {
  6. static get tableName() { return 'settings' }
  7. static get jsonSchema () {
  8. return {
  9. type: 'object',
  10. required: ['key', 'value'],
  11. properties: {
  12. id: {type: 'integer'},
  13. key: {type: 'string'},
  14. value: {type: 'object'},
  15. createdAt: {type: 'string'},
  16. updatedAt: {type: 'string'}
  17. }
  18. }
  19. }
  20. $beforeUpdate() {
  21. this.updatedAt = new Date().toISOString()
  22. }
  23. $beforeInsert() {
  24. this.createdAt = new Date().toISOString()
  25. this.updatedAt = new Date().toISOString()
  26. }
  27. }