UNPKG

@push.rocks/smartdata

Version:

An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.

43 lines (42 loc) 1.56 kB
import { SmartdataDb } from './classes.db.js'; /** * EasyStore allows the storage of easy objects. It also allows easy sharing of the object between different instances */ export declare class EasyStore<T> { smartdataDbRef: SmartdataDb; nameId: string; private easyStoreClass; constructor(nameIdArg: string, smartdataDbRefArg: SmartdataDb); private easyStorePromise?; private getEasyStore; /** * reads all keyValue pairs at once and returns them */ readAll(): Promise<Partial<T>>; /** * reads a keyValueFile from disk */ readKey<TKey extends keyof T>(keyArg: TKey): Promise<Partial<T>[TKey]>; /** * writes a specific key to the keyValueStore */ writeKey<TKey extends keyof T>(keyArg: TKey, valueArg: T[TKey]): Promise<void>; deleteKey(keyArg: keyof T): Promise<void>; /** * merges all keyValue pairs from the object argument into the store. * Existing keys that are not present in `keyValueObject` are preserved. * To overwrite the entire store and drop missing keys, use `replace()`. */ writeAll(keyValueObject: Partial<T>): Promise<void>; /** * atomically replaces the entire store with the given object. * Unlike `writeAll` (which merges), `replace` clears any keys not * present in `keyValueObject`. Useful when you need to drop a key. */ replace(keyValueObject: Partial<T>): Promise<void>; /** * wipes a key value store from disk */ wipe(): Promise<void>; cleanUpEphemeral(): Promise<void>; }