UNPKG

js-node-arango

Version:
89 lines (88 loc) 3.24 kB
import { AqlQuery } from 'arangojs/aql'; import { ArangoDocumentQueryOptions, ArangoEdgeQueryOptions, Filter, Primitive } from '../types/arango-query-options.interface'; export type BindVars = Record<string, Primitive | Primitive[]>; export declare class ArangoBaseQueryBuilder { protected options: ArangoDocumentQueryOptions | ArangoEdgeQueryOptions; protected bindVars: BindVars; protected additionalQueries: Map<string, ArangoBaseQueryBuilder>; protected withClause: string; protected selector: string; protected filter: string; protected sort: string; protected limit: string; protected doc: string; protected returnClause: string; protected inlineQueries: string; private _isRootQuery; private _tick; private _parent; constructor(options: ArangoDocumentQueryOptions | ArangoEdgeQueryOptions); prepareQuery(): AqlQuery; setDocSelector(doc: string): this; getDocSelector(): string; addAdditionalQuery(varName: string, q: ArangoBaseQueryBuilder): this; protected buildSelector(): void; protected buildFilter(): void; protected buildSort(): void; protected buildLimit(): void; protected buildWithClause(): void; protected gatherRelatedCollectionsRecursively(): string[]; protected buildReturnClause(): void; protected buildAdditionalQueries(): void; protected buildEverything(): void; private isFilterPrimitiveType; private isFilterProperFilterObject; /** * Flattens the provided filter object and returns an array with dot notation representation. * @example * ```js * // Given object: * const filter = { * gitRepoInfo: { * webhook: 12, * owner: { * name: 'Tospaa', * } * }, * state: 'InTest', * } * // Expected output: * [ * { * query: 'doc.gitRepoInfo.webhook == \@docgitRepoInfowebhook', * vars: { * bindVarName: 'docgitRepoInfowebhook', * value: 12 * } * }, * { * query: 'doc.gitRepoInfo.owner.name == \@docgitRepoInfoownername', * vars: { * bindVarName: 'docgitRepoInfoownername', * value: 'Tospaa' * } * }, * { * query: 'doc.gitRepoInfo.state == \@docgitRepoInfostate', * vars: { * bindVarName: 'docgitRepoInfostate', * value: 'InTest' * } * } * ] * ``` * @param filter Object provided to be flattened. * @param prevKey For recursive use only * @returns An array of filters */ protected extractFilters(filter: Filter, prevKey?: string): AqlQuery[]; protected handleCommaSeparated(values: string[], keyNameInput: string): string; protected checkSafe(phrase: string): void; protected concatArrays(array1: string[], array2: string | string[]): string[]; protected isRootQuery(): boolean; protected setParentQuery(parent: ArangoBaseQueryBuilder): void; protected getParentQuery(): ArangoBaseQueryBuilder | undefined; protected getTopmostParentQuery(): ArangoBaseQueryBuilder; protected getNextTick(): number; protected getNextGlobalTick(): number; }