mongo-bolt
Version:
A lightweight, beginner-friendly MongoDB wrapper with inbuilt caching and simplified joins/indexing.
65 lines (64 loc) • 2.3 kB
TypeScript
declare class AggregationBuilder {
private pipeline;
private lastGroupStage;
private ensureGroupStage;
match(field: string, condition: Record<string, any>): this;
group(groupBy: string | Record<string, any>): this;
sum(value: string, key: string): this;
avg(value: string, key: string): this;
min(value: string, key: string): this;
max(value: string, key: string): this;
first(value: string, key: string): this;
last(value: string, key: string): this;
push(field: string, key?: string): this;
addToSet(value: string, key: string): this;
stdDevPop(value: string, key: string): this;
stdDevSamp(value: string, key: string): this;
mergeObjects(value: string, key: string): this;
count(key?: string): this;
project(projection: Record<string, any>): this;
sort(sortFields: Record<string, "asc" | "desc">): this;
limit(n: number): this;
skip(n: number): this;
lookup(from: string, localField: string, foreignField: string, as: string): this;
unset(...fields: string[]): this;
addFields(fields: Record<string, any>): this;
replaceRoot(newRoot: any): this;
replaceWith(replacement: any): this;
graphLookup(options: {
from: string;
startWith: any;
connectFromField: string;
connectToField: string;
as: string;
maxDepth?: number;
depthField?: string;
restrictSearchWithMatch?: Record<string, any>;
}): this;
unwind(field: string | Record<string, any>): this;
bucket(options: {
groupBy: any;
boundaries: any[];
default?: any;
output: Record<string, any>;
}): this;
bucketAuto(options: {
groupBy: any;
buckets: number;
output?: Record<string, any>;
granularity?: string;
}): this;
facet(facets: Record<string, any[]>): this;
merge(options: string | Record<string, any>): this;
out(collectionName: string): this;
search(searchStage: Record<string, any>): this;
searchMeta(searchStage: Record<string, any>): this;
redact(expression: any): this;
indexStats(): this;
currentOp(): this;
collStats(): this;
planCacheStats(): this;
listSessions(): this;
build(): any[];
}
export default AggregationBuilder;