refactor: migrate to objection.js + knex
This commit is contained in:
31
server/db/models/settings.js
Normal file
31
server/db/models/settings.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const Model = require('objection').Model
|
||||
|
||||
/**
|
||||
* Settings model
|
||||
*/
|
||||
module.exports = class User extends Model {
|
||||
static get tableName() { return 'settings' }
|
||||
|
||||
static get jsonSchema () {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['key', 'value'],
|
||||
|
||||
properties: {
|
||||
id: {type: 'integer'},
|
||||
key: {type: 'string'},
|
||||
value: {type: 'object'},
|
||||
createdAt: {type: 'string'},
|
||||
updatedAt: {type: 'string'}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate() {
|
||||
this.updatedAt = new Date().toISOString()
|
||||
}
|
||||
$beforeInsert() {
|
||||
this.createdAt = new Date().toISOString()
|
||||
this.updatedAt = new Date().toISOString()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user