UNPKG

@varasto/query

Version:

Query and bulk operation utilities for Varasto storage

22 lines (21 loc) 1.17 kB
import { Entry, Storage } from '@varasto/storage'; import { Schema } from 'simple-json-match'; import { JsonObject } from 'type-fest'; /** * Searches for an entry from given namespace that matches given schema and * returns value of first matching result. If no entry in the namespace matches * the schema, `undefined` is returned instead. */ export declare function find<T extends JsonObject>(storage: Storage, namespace: string, schema: Schema): Promise<T | undefined>; /** * Searches for an entry from given namespace that matches given schema and * returns key of first matching result. If no entry in the namespace matches * the schema, `undefined` is returned instead. */ export declare function findKey(storage: Storage, namespace: string, schema: Schema): Promise<string | undefined>; /** * Searches for an entry from given namespace that matches given schema and * returns both key and value of first matching result. If no entry in the * namespace matches the schema, `undefined` is returned instead. */ export declare function findEntry<T extends JsonObject>(storage: Storage, namespace: string, schema: Schema): Promise<Entry<T> | undefined>;