unify audit fields, fixes #102

This commit is contained in:
azivner
2018-05-26 12:38:25 -04:00
parent 933cce1b94
commit 03bf33630e
9 changed files with 56 additions and 11 deletions

View File

@@ -27,7 +27,11 @@ class Branch extends Entity {
this.isDeleted = false;
}
this.dateModified = dateUtils.nowDate()
if (!this.dateCreated) {
this.dateCreated = dateUtils.nowDate();
}
this.dateModified = dateUtils.nowDate();
}
}

View File

@@ -1,11 +1,24 @@
"use strict";
const Entity = require('./entity');
const dateUtils = require('../services/date_utils');
class RecentNote extends Entity {
static get tableName() { return "recent_notes"; }
static get primaryKeyName() { return "branchId"; }
static get hashedProperties() { return ["branchId", "notePath", "dateAccessed", "isDeleted"]; }
static get hashedProperties() { return ["branchId", "notePath", "dateCreated", "isDeleted"]; }
beforeSaving() {
super.beforeSaving();
if (!this.isDeleted) {
this.isDeleted = false;
}
if (!this.dateCreated) {
this.dateCreated = dateUtils.nowDate();
}
}
}
module.exports = RecentNote;