2018-04-02 00:03:21 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Entity = require('./entity');
|
2018-05-27 00:38:25 +08:00
|
|
|
const dateUtils = require('../services/date_utils');
|
2018-04-02 00:03:21 +08:00
|
|
|
|
2018-08-23 05:37:06 +08:00
|
|
|
/**
|
|
|
|
* RecentNote represents recently visited note.
|
|
|
|
*
|
2019-11-09 16:36:08 +08:00
|
|
|
* @property {string} noteId
|
|
|
|
* @property {string} notePath
|
|
|
|
* @property {boolean} isDeleted
|
|
|
|
* @property {string} utcDateModified
|
2018-08-23 05:37:06 +08:00
|
|
|
*
|
|
|
|
* @extends Entity
|
|
|
|
*/
|
2018-04-02 00:03:21 +08:00
|
|
|
class RecentNote extends Entity {
|
2018-08-17 05:00:04 +08:00
|
|
|
static get entityName() { return "recent_notes"; }
|
2019-05-22 03:47:28 +08:00
|
|
|
static get primaryKeyName() { return "noteId"; }
|
|
|
|
static get hashedProperties() { return ["noteId", "notePath", "utcDateCreated", "isDeleted"]; }
|
2018-05-27 00:38:25 +08:00
|
|
|
|
|
|
|
beforeSaving() {
|
|
|
|
if (!this.isDeleted) {
|
|
|
|
this.isDeleted = false;
|
|
|
|
}
|
|
|
|
|
2019-03-13 03:58:31 +08:00
|
|
|
if (!this.utcDateCreated) {
|
2019-03-14 05:43:59 +08:00
|
|
|
this.utcDateCreated = dateUtils.utcNowDateTime();
|
2018-05-27 00:38:25 +08:00
|
|
|
}
|
2018-08-06 14:59:26 +08:00
|
|
|
|
|
|
|
super.beforeSaving();
|
2018-05-27 00:38:25 +08:00
|
|
|
}
|
2018-04-02 00:03:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = RecentNote;
|