diff --git a/src/api.js b/src/api.js index a26b96a..ba3b2b9 100644 --- a/src/api.js +++ b/src/api.js @@ -4,7 +4,37 @@ * @date 2020/08/31 15:46:20 */ -import Method from './method.js' +class Method { + constructor(table) { + this.table = table + } + + put(obj) { + this.table.put(obj) + } + + get(id) { + var res = this.table.get(id) + return new Promise(resolve => { + res.onsuccess = function (ev) { + resolve(this.result) + } + }) + } + + getAll() { + var res = this.table.getAll() + return new Promise(resolve => { + res.onsuccess = function (ev) { + resolve(this.result) + } + }) + } + + delete(id) { + this.table.delete(id) + } +} export default class Api { constructor(db) { diff --git a/src/index.js b/src/index.js index f91b15e..715cd85 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,7 @@ * @date 2023/04/11 15:10:04 */ -import { defer, createTable } from './helper.js' +import { defer } from './helper.js' import Api from './api.js' export function createStore(name, version = 1) { diff --git a/src/method.js b/src/method.js deleted file mode 100644 index 2f7c604..0000000 --- a/src/method.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * {} - * @author yutent - * @date 2023/04/11 15:11:31 - */ - -export default class Method { - constructor(table) { - this.table = table - } - - put(obj) { - this.table.put(obj) - } - - get(id) { - var res = this.table.get(id) - return new Promise(resolve => { - res.onsuccess = function (ev) { - resolve(this.result) - } - }) - } - - getAll() { - var res = this.table.getAll() - return new Promise(resolve => { - res.onsuccess = function (ev) { - resolve(this.result) - } - }) - } - - delete(id) { - this.table.delete(id) - } -}