mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
feat: impl database structure
This commit is contained in:
26
packages/core/database/storage.js
Normal file
26
packages/core/database/storage.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import Convert from "../utils/convert";
|
||||
|
||||
export default 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);
|
||||
}
|
||||
encrypt(password, data) {
|
||||
return this.storage.encrypt(password, data);
|
||||
}
|
||||
decrypt(password, cipher) {
|
||||
return this.storage.decrypt(password, cipher);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user