import { GenericObject } from "@mongez/reinforcements"; import { ChunkCallback, Filter, PaginationListing } from "../model"; import { ModelEvents } from "../model/model-events"; import { GroupByPipeline } from "./GroupByPipeline"; import { LookupPipelineOptions } from "./LookupPipeline"; import { UnwindOptions } from "./UnwindPipeline"; import { Pipeline } from "./pipeline"; import { WhereOperator } from "./types"; export declare class Aggregate { readonly collection: string; /** * Collection pipelines */ protected pipelines: Pipeline[]; /** * Aggregate events */ static _events: ModelEvents; /** * Query manager */ query: import("../query").Query; /** * Constructor */ constructor(collection: string); /** * Get the events instance */ static events(): ModelEvents; /** * Sort by the given column */ sort(column: string, direction?: "asc" | "desc"): this; /** * @alias sort */ orderBy(column: string, direction?: "asc" | "desc"): this; /** * Order by descending */ sortByDesc(column: string): this; /** * Order by descending */ orderByDesc(column: string): this; /** * Sort by multiple columns */ sortBy(columns: Record): this; /** * Sort randomly */ random(limit?: number): this; /** * Order by latest created records */ latest(column?: string): this; /** * Order by oldest created records */ oldest(column?: string): this; /** * Group by aggregate */ groupBy(GroupByPipeline: GroupByPipeline): this; groupBy(GroupByPipeline: GenericObject, groupByData?: GenericObject): this; groupBy(groupByColumns: string[], groupByData?: GenericObject): this; groupBy(groupBy_id: string | null): this; groupBy(groupBy_id: string | null, groupByData: GenericObject): this; /** * Group by year */ groupByYear(column: string, groupByData?: GenericObject): this; /** * Group by month and year */ groupByMonthAndYear(column: string, groupByData?: GenericObject): this; /** * Group by month only */ groupByMonth(column: string, groupByData?: GenericObject): this; /** * Group by day, month and year */ groupByDate(column: string, groupByData?: GenericObject): this; /** * Group by day only */ groupByDayOfMonth(column: string, groupByData?: GenericObject): this; /** * Pluck only the given column */ pluck(column: string): Promise; /** * Get average of the given column */ avg(column: string): Promise; /** * {@alias} avg */ average(column: string): Promise; /** * Sum values of the given column */ sum(column: string): Promise; /** * Get minimum value of the given column */ min(column: string): Promise; /** * Get maximum value of the given column */ max(column: string): Promise; /** * Get distinct value for the given column using aggregation */ distinct(column: string): Promise; /** * {@alias} distinct */ unique(column: string): Promise; /** * Get distinct values that are not empty */ distinctHeavy(column: string): Promise; /** * {@alias} distinctHeavy */ uniqueHeavy(column: string): Promise; /** * Get values list of the given column */ values(column: string): Promise; /** * Limit the number of results */ limit(limit: number): this; /** * Skip the given number of results */ skip(skip: number): this; /** * Select the given columns */ select(columns: string[] | Record): this; /** * Deselect the given columns */ deselect(columns: string[]): this; /** * Unwind/Extract the given column */ unwind(column: string, options?: UnwindOptions): this; /** * Add where stage */ where(column: string, value: any): this; where(column: string, operator: WhereOperator, value: any): this; where(column: GenericObject): this; /** * Add comparison between two or more columns */ whereColumns(column1: string, operator: WhereOperator, ...otherColumns: string[]): this; /** * Or Where stage */ orWhere(column: GenericObject): this; /** * Where null */ whereNull(column: string): this; /** * Where not null */ whereNotNull(column: string): this; /** * Where like operator */ whereLike(column: string, value: string): this; /** * Where not like operator */ whereNotLike(column: string, value: string): this; /** * Where column starts with the given value */ whereStartsWith(column: string, value: string | number): this; /** * Where column not starts with the given value */ whereNotStartsWith(column: string, value: string | number): this; /** * Where column ends with the given value */ whereEndsWith(column: string, value: string | number): this; /** * Where column not ends with the given value */ whereNotEndsWith(column: string, value: string | number): this; /** * Where between operator */ whereBetween(column: string, value: [any, any]): this; /** * Where date between operator */ whereDateBetween(column: string, value: [Date, Date]): this; /** * Where date not between operator */ whereDateNotBetween(column: string, value: [Date, Date]): this; /** * Where not between operator */ whereNotBetween(column: string, value: [any, any]): this; /** * Where exists operator */ whereExists(column: string): this; /** * Where not exists operator */ whereNotExists(column: string): this; /** * Where size operator */ whereSize(column: string, size: number): this; whereSize(column: string, operator: ">" | ">=" | "=" | "<" | "<=", size: number): this; /** * Add project pipeline * */ project(data: Record): this; /** * Where in operator * If value is a string, it will be treated as a column name */ whereIn(column: string, values: string | any[]): this; /** * Where not in operator * If value is a string, it will be treated as a column name */ whereNotIn(column: string, values: string | any[]): this; /** * // TODO: Make a proper implementation * Where location near */ whereNear(column: string, value: [number, number], _distance: number): this; /** * // TODO: Make a proper implementation * Get nearby location between the given min and max distance */ whereNearByIn(column: string, value: [number, number], _inDistance: number, _maxDistance: number): Promise; /** * Lookup the given collection */ lookup(options: LookupPipelineOptions): this; /** * Add field to the pipeline */ addField(field: string, value: any): this; /** * Add fields to the pipeline */ addFields(fields: GenericObject): this; /** * Get new pipeline instance */ pipeline(pipeline: Pipeline): this; /** * Add mongodb plain stage */ addPipeline(pipeline: any): this; /** * Add mongodb plain stages */ addPipelines(pipelines: any[]): this; /** * Get only first result */ first(mapData?: (data: any) => any): Promise; /** * Get last result */ last(filters?: Filter): Promise; /** * Delete records */ delete(): Promise; /** * Get the data */ get(mapData?: (data: any) => any): Promise; /** * Chunk documents based on the given limit */ chunk(limit: number, callback: ChunkCallback, mapData?: (data: any) => any): Promise; /** * Paginate records based on the given filter */ paginate(page?: number, limit?: number, mapData?: (data: any) => T): Promise>; /** * Explain the query */ explain(): Promise; /** * Update the given data */ update(data: any): Promise; /** * Unset the given columns */ unset(...columns: string[]): Promise; /** * Execute the query */ execute(): Promise; /** * Count the results */ count(): Promise; /** * Parse pipelines */ parse(): any[]; /** * Reset the pipeline */ reset(): this; /** * Clone the aggregate class */ clone(): this; } //# sourceMappingURL=aggregate.d.ts.map