groq-builder
Version:
A **schema-aware**, strongly-typed GROQ query builder. It enables you to build GROQ queries using **auto-completion**, **type-checking**, and **runtime validation**.
15 lines (14 loc) • 1.14 kB
TypeScript
import { RequireAFakeParameterIfThereAreTypeMismatchErrors, Simplify } from "../types/utils";
import { ResultItem } from "../types/result-types";
import { ExtractProjectionResult, ProjectionMap } from "./projection-types";
declare module "../groq-builder" {
interface GroqBuilder<TResult, TQueryConfig> {
/**
* Performs an "object projection", returning an object with the fields specified.
*
* @param projectionMap - The projection map is an object, mapping field names to projection values
* @param __projectionMapTypeMismatchErrors - (internal; this is only used for reporting errors from the projection)
*/
project<TProjection extends ProjectionMap<ResultItem.Infer<TResult>>, _TProjectionResult = ExtractProjectionResult<ResultItem.Infer<TResult>, TProjection>>(projectionMap: TProjection | ((q: GroqBuilder<ResultItem.Infer<TResult>, TQueryConfig>) => TProjection), ...__projectionMapTypeMismatchErrors: RequireAFakeParameterIfThereAreTypeMismatchErrors<_TProjectionResult>): GroqBuilder<ResultItem.Override<TResult, Simplify<_TProjectionResult>>, TQueryConfig>;
}
}