context menu, editing connection

This commit is contained in:
Jan Prochazka
2020-01-04 15:09:03 +01:00
parent b6599803b7
commit 4c52e1eb27
12 changed files with 439 additions and 15 deletions

View File

@@ -14,7 +14,7 @@ module.exports = {
const dir = await datadir();
this.datastore = nedb.create(path.join(dir, 'connections.jsonl'));
},
list_meta: 'get',
async list() {
return this.datastore.find();
@@ -32,7 +32,15 @@ module.exports = {
save_meta: 'post',
async save(connection) {
const res = await this.datastore.insert(connection);
return res;
if (connection._id) {
return await this.datastore.update(_.pick(connection, '_id'), connection);
} else {
return await this.datastore.insert(connection);
}
},
delete_meta: 'post',
async delete(connection) {
return await this.datastore.remove(_.pick(connection, '_id'));
},
};