You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
813 B

  1. const Model = require('objection').Model
  2. /**
  3. * Locales model
  4. */
  5. module.exports = class Locale 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. isRTL: {type: 'boolean', default: false},
  15. name: {type: 'string'},
  16. nativeName: {type: 'string'},
  17. createdAt: {type: 'string'},
  18. updatedAt: {type: 'string'}
  19. }
  20. }
  21. }
  22. static get jsonAttributes() {
  23. return ['strings']
  24. }
  25. $beforeUpdate() {
  26. this.updatedAt = new Date().toISOString()
  27. }
  28. $beforeInsert() {
  29. this.createdAt = new Date().toISOString()
  30. this.updatedAt = new Date().toISOString()
  31. }
  32. }