add delete functionality

This commit is contained in:
Philipp Kunz 2017-07-12 17:22:22 +02:00
parent 854dac5732
commit 9883067d8b
2 changed files with 9 additions and 1 deletions

View File

@ -33,6 +33,10 @@ class KeyValueStore {
execDelay: 500, execDelay: 500,
taskFunction: () => __awaiter(this, void 0, void 0, function* () { taskFunction: () => __awaiter(this, void 0, void 0, function* () {
this.dataObject = plugins.smartlodash.merge({}, plugins.smartfile.fs.toObjectSync(this.filePath), this.dataObject); this.dataObject = plugins.smartlodash.merge({}, plugins.smartfile.fs.toObjectSync(this.filePath), this.dataObject);
for (let key in this.deletedObject) {
delete this.dataObject[key];
}
this.deletedObject = {};
yield plugins.smartfile.memory.toFs(JSON.stringify(this.dataObject), this.filePath); yield plugins.smartfile.memory.toFs(JSON.stringify(this.dataObject), this.filePath);
}), }),
name: 'syncTask' name: 'syncTask'
@ -110,4 +114,4 @@ class KeyValueStore {
} }
} }
exports.KeyValueStore = KeyValueStore; exports.KeyValueStore = KeyValueStore;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEuY2xhc3Nlcy5rZXl2YWx1ZXN0b3JlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZXh0cmEuY2xhc3Nlcy5rZXl2YWx1ZXN0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSw4Q0FBNkM7QUFDN0MsMENBQXlDO0FBRXpDLDJDQUEyQztBQUkzQzs7R0FFRztBQUNIO0lBNkJFOzs7O09BSUc7SUFDSCxZQUFZLE9BQXVCLEVBQUUsZUFBdUI7UUFoQzVELGtCQUFhLEdBQVEsRUFBRSxDQUFBO1FBQ3ZCLG9CQUFlLEdBQUcsSUFBSSxxQkFBUSxDQUFDO1lBQzdCLFlBQVksRUFBRTtnQkFDWixJQUFJLENBQUMsVUFBVSxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQU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U0FBUyxDQUFDLEVBQUUsQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQ25ELE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFBO0lBQzFELENBQUM7Q0FDRjtBQTFHRCxzQ0EwR0MifQ==

View File

@ -26,6 +26,10 @@ export class KeyValueStore {
plugins.smartfile.fs.toObjectSync(this.filePath), plugins.smartfile.fs.toObjectSync(this.filePath),
this.dataObject this.dataObject
) )
for (let key in this.deletedObject) {
delete this.dataObject[key]
}
this.deletedObject = {}
await plugins.smartfile.memory.toFs( await plugins.smartfile.memory.toFs(
JSON.stringify(this.dataObject), JSON.stringify(this.dataObject),
this.filePath this.filePath