import { GeneratedAqlQuery } from 'arangojs/aql.js'; import { AqProperty, AqAggregate, AqSort, AqFilter, SortDirection, AqlAggregateFunction } from './property.js'; import { AqStrict, AqQuery, AqRemove } from './query.js'; import { JsonPrimitive } from '@salesforce/ts-types'; import { ArangoCollection } from 'arangojs/collection.js'; /** * A fluent wrapper for a {@link AqStrict} structure, with functions to build * a {@link GeneratedAqlQuery} object from the spec. * * @example Fluent chainable methods * ``` * const generatedAql = new AqBuilder('my_collection') * .filterBy('property.nestedProperty', 'value') * .sortBy('prop3', 'asc') * .limit(100) * .return('prop1') * .return('prop2', 'customLabel') * .build(); * ``` * @example AqQuery structure * ``` * const generatedAql = AqBuilder.build({ * collection: 'my_collection', * filters: [{ property: 'property.nestedProperty', eq: 'value'}], * sorts: [{ property: 'prop3', direction: 'asc' }], * limit: 100, * return: [ * { property: 'prop1' }, * { property: 'prop2', label: 'customLabel' }, * ], * }); * ``` */ export declare class AqBuilder { /** * A JSON structure defining the Query's properties, filters, sorts, etc. * * Although it may be altered directly, the {@link AqBuilder} class's chainable * methods are the intended mechanism for building and managing its spec structure. */ spec: AqStrict; /** * Convenience wrapper for the {@link buildQuery} function. */ static build(input: AqStrict | AqQuery): GeneratedAqlQuery; /** * Builds a {@link GeneratedAqlQuery} based on the instance's {@link AqStrict}. */ build(): GeneratedAqlQuery; /** * Returns a new {@link AqBuilder} containing a buildable {@link AqStrict}. */ constructor(input: string | ArangoCollection | AqStrict | AqQuery, document?: string); /** * Adds a descriptive comment to the query; there is no effect on the query results. */ comment(input: string): this; /** * Adds a property to the query results. * * @remarks * If any {@link AqAggregate} properties exist on the query, these * properties will be transformed into COLLECT assignments when * the final query is built. */ return(name: string | AqProperty, path?: string): this; /** * Delete matching documents from the collection. */ remove(): this; remove(clause?: AqRemove): this; remove(collection?: string | ArangoCollection): this; /** * Groups query results by the values in a given property. */ groupBy(definition: AqAggregate): this; /** * Groups query results by the values in a given property. */ groupBy(name: string, path?: string): this; /** * Groups query results by the values in a given property. */ collect(definition: AqAggregate): this; /** * Groups query results by the values in a given property. */ collect(name: string, path?: string): this; /** * Adds an aggregate property to the query results that summarizes a particular * property's values, in conjunction with a collect/groupBy statement. */ aggregate(name: string, func?: AqlAggregateFunction, path?: string): this; /** * Adds an aggregate property to the query results that summarizes a particular * property's values, in conjunction with a collect/groupBy statement. */ aggregate(definition: AqAggregate): this; /** * Filters query results by a particular property's value. * * @remarks * The order in which the query is built matters: if 'groupBy' or 'aggregate' * clauses have already been added, the filter will apply to the post-aggregation * values. */ filterBy(name: string, value?: JsonPrimitive | JsonPrimitive[]): this; /** * Filters query results by a particular property's value. * * @remarks * The order in which the query is built matters: if 'groupBy' or 'aggregate' * clauses have already been added, the filter will apply to the post-aggregation * values. */ filterBy(definition: AqFilter): this; /** * Sorts the query results by a particular property value. */ sortBy(name: string | null, direction?: SortDirection): this; /** * Sorts the query results by a particular property value. */ sortBy(definition: AqSort): this; /** * Limits the number of results returned. */ limit(value: number | undefined): this; /** * Changes the name of the 'count' property generated when aggregating data. Setting * count to 'false' will remove the auto-calculated property from the query results entirely. */ count(label: string | false): this; } //# sourceMappingURL=builder.d.ts.map