2018-03-09 17:49:35 +00:00
|
|
|
const BaseModel = require("lib/BaseModel.js");
|
|
|
|
const BaseItem = require("lib/models/BaseItem.js");
|
2017-12-12 18:41:02 +00:00
|
|
|
|
|
|
|
class MasterKey extends BaseItem {
|
|
|
|
static tableName() {
|
2018-03-09 17:49:35 +00:00
|
|
|
return "master_keys";
|
2017-12-12 18:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static modelType() {
|
|
|
|
return BaseModel.TYPE_MASTER_KEY;
|
|
|
|
}
|
|
|
|
|
2017-12-13 18:57:40 +00:00
|
|
|
static encryptionSupported() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-14 19:39:13 +00:00
|
|
|
static latest() {
|
2018-03-09 17:49:35 +00:00
|
|
|
return this.modelSelectOne("SELECT * FROM master_keys WHERE created_time >= (SELECT max(created_time) FROM master_keys)");
|
2017-12-14 19:39:13 +00:00
|
|
|
}
|
|
|
|
|
2017-12-13 18:57:40 +00:00
|
|
|
static async serialize(item, type = null, shownKeys = null) {
|
|
|
|
let fieldNames = this.fieldNames();
|
2018-03-09 17:49:35 +00:00
|
|
|
fieldNames.push("type_");
|
|
|
|
return super.serialize(item, "master_key", fieldNames);
|
2017-12-13 18:57:40 +00:00
|
|
|
}
|
|
|
|
|
2017-12-14 19:39:13 +00:00
|
|
|
static async save(o, options = null) {
|
2018-03-09 17:49:35 +00:00
|
|
|
return super.save(o, options).then(item => {
|
2017-12-14 19:39:13 +00:00
|
|
|
this.dispatch({
|
2018-03-09 17:49:35 +00:00
|
|
|
type: "MASTERKEY_UPDATE_ONE",
|
2017-12-14 19:39:13 +00:00
|
|
|
item: item,
|
|
|
|
});
|
|
|
|
return item;
|
|
|
|
});
|
|
|
|
}
|
2017-12-12 18:41:02 +00:00
|
|
|
}
|
|
|
|
|
2018-03-09 17:49:35 +00:00
|
|
|
module.exports = MasterKey;
|