#12 audit and history
This commit is contained in:
@@ -12,7 +12,7 @@ class ScenariosManager{
|
||||
* @param {App} app Class initializer, основна апликация
|
||||
*/
|
||||
init(app){
|
||||
const {db} = app;
|
||||
const {db, am} = app;
|
||||
|
||||
/**
|
||||
* Creates a new scenario, създаване на нов сценарий
|
||||
@@ -43,6 +43,7 @@ class ScenariosManager{
|
||||
this.update = async function(ctx, data){
|
||||
data.id = parseInt(data.id);
|
||||
let object = await this.read(data.id);
|
||||
await am.addToHistory(object, collection, 'update');
|
||||
data = Object.assign(object, data);
|
||||
await db.update(collection, {id: data.id}, data);
|
||||
return data;
|
||||
@@ -54,6 +55,7 @@ class ScenariosManager{
|
||||
*/
|
||||
this.remove = async function(id){
|
||||
id = parseInt(id);
|
||||
await am.addToHistory(id, collection, 'delete');
|
||||
await db.remove(collection, {id});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user