2018-04-02 05:38:24 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Entity = require('./entity');
|
2018-04-03 08:46:46 +08:00
|
|
|
const dateUtils = require('../services/date_utils');
|
2018-04-02 05:38:24 +08:00
|
|
|
|
|
|
|
class ApiToken extends Entity {
|
|
|
|
static get tableName() { return "api_tokens"; }
|
|
|
|
static get primaryKeyName() { return "apiTokenId"; }
|
2018-05-23 10:22:15 +08:00
|
|
|
static get hashedProperties() { return ["apiTokenId", "token", "dateCreated", "isDeleted"]; }
|
2018-04-02 05:38:24 +08:00
|
|
|
|
|
|
|
beforeSaving() {
|
2018-04-03 08:30:00 +08:00
|
|
|
super.beforeSaving();
|
2018-04-02 05:38:24 +08:00
|
|
|
|
|
|
|
if (!this.isDeleted) {
|
|
|
|
this.isDeleted = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.dateCreated) {
|
2018-04-03 08:46:46 +08:00
|
|
|
this.dateCreated = dateUtils.nowDate();
|
2018-04-02 05:38:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ApiToken;
|