@signaldb/core
Version:
SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON in
20 lines (19 loc) • 968 B
TypeScript
import type { BaseItem } from '../Collection/types';
import type { FlatSelector } from '../types/Selector';
type KeyResult = {
include: string[] | null;
exclude: string[] | null;
};
/**
* Extracts the matching and excluded keys for a given field in a selector.
* Supports serialized values and `$in`/`$nin` field expressions for optimization.
* Returns `null` for include/exclude if the field cannot be optimized.
* @template T - The type of the items in the selector.
* @template I - The type of the unique identifier for the items.
* @param field - The name of the field to extract matching keys for.
* @param selector - The selector object containing query criteria.
* @returns An object containing arrays of serialized included and excluded keys,
* or `null` if the field cannot be optimized.
*/
export default function getMatchingKeys<T extends BaseItem<I> = BaseItem, I = any>(field: string, selector: FlatSelector<T>): KeyResult;
export {};