@tekbox/unified-storage
v0.0.8
Published
Unified-Storage is a simple key value storage interface for different backends. For currently available storage backends check src/adapters. To write your own storage adapter just extend AbstractStorageAdapter.
Downloads
7
Readme
@tekbox/unified-storage
Unified-Storage is a simple key value storage interface for different backends. For currently available storage backends check src/adapters. To write your own storage adapter just extend AbstractStorageAdapter.
Usage
Available methods:
export interface IUnifiedStorage {
set(key: string, value: any): ThenPromise<boolean>;
get(key: string): ThenPromise<any>;
rm(key: string): ThenPromise<boolean>;
exists(key: string): ThenPromise<boolean>;
dump(): ThenPromise<{name: string, data: any[]}>;
}
Usage:
const storage = new UnifiedStorage();
const storage2 = new UnifiedStorage("test", new FilesystemStorageAdapter("./data", "test"));
storage.set("key", "value")
.then((data) => {
...
})
.catch((err) => {
...
})
...
storage.get("key")
.then((data) => {
...
})
.catch((err) => {
...
});