mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
api: add basic (local) database api using storage
This commit is contained in:
22
packages/core/helpers/storage.js
Normal file
22
packages/core/helpers/storage.js
Normal 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;
|
||||
Reference in New Issue
Block a user