locales.js 786 B

12345678910111213141516171819202122232425262728293031323334
  1. const Model = require('objection').Model
  2. /**
  3. * Locales model
  4. */
  5. module.exports = class User extends Model {
  6. static get tableName() { return 'locales' }
  7. static get idColumn() { return 'code' }
  8. static get jsonSchema () {
  9. return {
  10. type: 'object',
  11. required: ['code', 'name'],
  12. properties: {
  13. code: {type: 'string'},
  14. strings: {type: 'object'},
  15. isRTL: {type: 'boolean', default: false},
  16. name: {type: 'string'},
  17. nativeName: {type: 'string'},
  18. createdAt: {type: 'string'},
  19. updatedAt: {type: 'string'}
  20. }
  21. }
  22. }
  23. $beforeUpdate() {
  24. this.updatedAt = new Date().toISOString()
  25. }
  26. $beforeInsert() {
  27. this.createdAt = new Date().toISOString()
  28. this.updatedAt = new Date().toISOString()
  29. }
  30. }