mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
smaller refactorings continued
This commit is contained in:
25
src/entities/api_token.js
Normal file
25
src/entities/api_token.js
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
const Entity = require('./entity');
|
||||
const utils = require('../services/utils');
|
||||
|
||||
class ApiToken extends Entity {
|
||||
static get tableName() { return "api_tokens"; }
|
||||
static get primaryKeyName() { return "apiTokenId"; }
|
||||
|
||||
beforeSaving() {
|
||||
if (!this.apiTokenId) {
|
||||
this.apiTokenId = utils.newApiTokenId();
|
||||
}
|
||||
|
||||
if (!this.isDeleted) {
|
||||
this.isDeleted = false;
|
||||
}
|
||||
|
||||
if (!this.dateCreated) {
|
||||
this.dateCreated = utils.nowDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ApiToken;
|
||||
Reference in New Issue
Block a user