This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/storage/idb/store.js

24 lines
451 B
JavaScript
Raw Normal View History

2019-02-05 04:51:50 +05:30
import QueryTarget from "./query-target.js";
2019-02-07 05:50:27 +05:30
import { reqAsPromise } from "./utils.js";
2019-02-05 04:51:50 +05:30
export default class Store extends QueryTarget {
2019-02-11 01:55:29 +05:30
constructor(idbStore) {
super(idbStore);
2019-02-05 04:51:50 +05:30
}
2019-02-11 01:55:29 +05:30
get _idbStore() {
2019-02-07 05:50:27 +05:30
return this._target;
2019-02-05 04:51:50 +05:30
}
index(indexName) {
2019-02-11 01:55:29 +05:30
return new QueryTarget(this._idbStore.index(indexName));
2019-02-07 05:50:27 +05:30
}
put(value) {
2019-02-11 01:55:29 +05:30
return reqAsPromise(this._idbStore.put(value));
2019-02-07 05:50:27 +05:30
}
add(value) {
2019-02-11 01:55:29 +05:30
return reqAsPromise(this._idbStore.add(value));
2019-02-05 04:51:50 +05:30
}
}