2018-05-19 20:40:07 +00:00
|
|
|
const Model = require('objection').Model
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locales model
|
|
|
|
*/
|
2019-02-10 00:10:34 +00:00
|
|
|
module.exports = class Locale extends Model {
|
2018-05-19 20:40:07 +00:00
|
|
|
static get tableName() { return 'locales' }
|
2018-09-08 19:49:36 +00:00
|
|
|
static get idColumn() { return 'code' }
|
2018-05-19 20:40:07 +00:00
|
|
|
|
|
|
|
static get jsonSchema () {
|
|
|
|
return {
|
|
|
|
type: 'object',
|
|
|
|
required: ['code', 'name'],
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
code: {type: 'string'},
|
|
|
|
isRTL: {type: 'boolean', default: false},
|
|
|
|
name: {type: 'string'},
|
|
|
|
nativeName: {type: 'string'},
|
|
|
|
createdAt: {type: 'string'},
|
|
|
|
updatedAt: {type: 'string'}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-10 00:10:34 +00:00
|
|
|
static get jsonAttributes() {
|
|
|
|
return ['strings']
|
|
|
|
}
|
|
|
|
|
2018-05-19 20:40:07 +00:00
|
|
|
$beforeUpdate() {
|
|
|
|
this.updatedAt = new Date().toISOString()
|
|
|
|
}
|
|
|
|
$beforeInsert() {
|
|
|
|
this.createdAt = new Date().toISOString()
|
|
|
|
this.updatedAt = new Date().toISOString()
|
|
|
|
}
|
|
|
|
}
|