Backend
This commit is contained in:
src/backend
app.jsdb.jsindex.js
internal
lib
logger.jsmigrate.jsmigrations
models
routes
schema
setup.jsviews
35
src/backend/models/user.js
Normal file
35
src/backend/models/user.js
Normal file
@ -0,0 +1,35 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
'use strict';
|
||||
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class User extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = Model.raw('NOW()');
|
||||
this.modified_on = Model.raw('NOW()');
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
this.modified_on = Model.raw('NOW()');
|
||||
}
|
||||
|
||||
static get name () {
|
||||
return 'User';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
return ['roles'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = User;
|
Reference in New Issue
Block a user