api: add basic (local) database api using storage

This commit is contained in:
thecodrr
2019-11-27 21:41:03 +05:00
parent f9da816372
commit f6056e52d0
2 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import Convert from "../utils/convert";
class Storage {
constructor(context) {
this.storage = context;
}
async write(key, data) {
await this.storage.write(key, Convert.toString(data));
}
async read(key) {
let data = await this.storage.read(key);
return Convert.fromString(data);
}
clear() {
this.storage.clear();
}
remove(key) {
this.storage.remove(key);
}
}
export default Storage;