- fix Indexdb:

1) ReadAllData 'GET'  : OK
 2) InsertTodo 'POST'  : OK
 3) DeleteItem 'DELETE': OK
 4) Modify     'PATCH' : OK
This commit is contained in:
Paolo Arena
2019-02-03 00:51:58 +01:00
parent 185bd2657d
commit 5db5fb7dd0
5 changed files with 77 additions and 65 deletions

View File

@@ -1,4 +1,4 @@
let idbKeyval = (() => {
let let idbKeyval = (() => {
let db;
function getDB() {
@@ -47,6 +47,7 @@ let idbKeyval = (() => {
},
async getdata(table, key) {
let req;
await withStore('readonly', table, store => {
console.log('store', store, 'key', key)
req = store.get(key);
@@ -62,24 +63,20 @@ let idbKeyval = (() => {
return req.result;
},
async set(key, value) {
return await withStore('readwrite', 'keyval', store => {
store.put(value, key);
let req;
await withStore('readwrite', 'keyval', store => {
req = store.put(value, key);
});
return req.result;
},
async setdata(table, valuekey) {
let value = []
if (table === 'delete_todos') {
value['_id'] = valuekey
}else {
value = valuekey
}
async setdata(table, value) {
let req;
console.log('setdata', table, value)
return await withStore('readwrite', table, store => {
store.put(value);
await withStore('readwrite', table, store => {
req = store.put(value);
});
return req.result;
},
async delete(key) {
return await withStore('readwrite', 'keyval', store => {