import { MongoClient } from "mongodb";
import { QueryLogic } from "../queries/QueryLogic";
import { IAggregateOptions, IDocumentClass, IDocumentInstance, IGranularity, IRepositoryOptions } from "../types";
import { AggregateAsyncIterator } from "./AggregateAsyncIterator";
type IExpression = any;
type IMapExpression = {
[key: string]: IExpression;
};
type IMapArrayExpression = {
[key: string]: IExpression[];
};
export declare class Aggregate
, RD extends any = {
[key: string]: any;
}> {
readonly mongoClient: MongoClient;
readonly classObject: TD;
readonly dbName: string;
readonly collectionName: string;
readonly aggregateOptions: IAggregateOptions;
nativePipeline: Array<{
[key: string]: any;
}>;
private _toDocument;
constructor(options: IRepositoryOptions | , aggregateOptions?: IAggregateOptions);
addFields(expression: IMapExpression): this;
bucket(options: {
groupBy: IExpression;
boundaries: any[];
default?: string;
output?: IMapExpression;
}): this;
bucketAuto(options: {
groupBy: IExpression;
buckets: number;
output?: IMapExpression;
granularity?: IGranularity;
}): this;
collStats(options: {
latencyStats?: {
histograms?: boolean;
};
storageStats?: {
scale?: number;
};
count?: {};
queryExecStats?: {};
}): this;
count(fieldName: K | string): this;
currentOp(options: {
allUsers?: boolean;
idleConnections?: boolean;
idleCursors?: boolean;
idleSessions?: boolean;
localOps?: boolean;
}): this;
facet(options: IMapArrayExpression): this;
geoNear(options: {
near: object;
distanceField: string;
spherical?: boolean;
maxDistance?: number;
query?: any;
distanceMultiplier?: number;
includeLocs?: string;
uniqueDocs?: boolean;
minDistance?: number;
key?: string;
}): this;
graphLookup(options: {
from: string;
startWith: IExpression;
connectFromField: string;
connectToField: string;
as: string;
maxDepth?: number;
depthField?: string;
restrictSearchWithMatch?: string;
}): this;
group(expression: IMapExpression): this;
indexStats(): this;
limit(value: number): this;
listLocalSessions(options: {
users?: Array<{
user: string;
db: string;
}>;
allUsers?: true;
}): this;
listSessions(options: {
users?: Array<{
user: string;
db: string;
}>;
allUsers?: true;
}): this;
lookup(options: {
from: string;
as: string;
localField?: string;
foreignField?: string;
let?: IMapExpression;
pipeline?: any[];
}): this;
match(expression: (query: QueryLogic) => any): this;
merge(options: {
into: string | {
db: string;
coll: string;
};
on?: string | string[];
let?: IMapExpression;
whenMatched?: "replace" | "keepExisting" | "merge" | "fail" | "pipeline";
whenNotMatched?: "insert" | "discard" | "fail";
}): this;
out(options: string | {
db: string;
coll: string;
}): this;
planCacheStats(): this;
project(expression: {
[key: string]: 1 | 0 | boolean | IExpression;
}): this;
redact(expression: IExpression): this;
replaceRoot(expression: {
newRoot: IExpression;
}): this;
replaceWith(expression: IExpression): this;
sample(value: number): this;
set(expression: IMapExpression): this;
skip(value: number): this;
sort(expression: {
[key: string]: 1 | -1 | {
$meta: "textScore";
};
}): this;
sortByCount(fieldName: IExpression): this;
unionWith(options: string | {
coll: string;
pipeline: any[];
}): this;
unset(fieldNames: string | string[]): this;
unwind(fieldName: string | {
path: string;
includeArrayIndex?: string;
preserveNullAndEmptyArrays?: boolean;
}): this;
toDocument(): Aggregate| >;
getAsyncIterator(): AggregateAsyncIterator | ;
explain(): Promise;
findOne(): Promise;
findMany(): Promise;
private _getCursor;
private _createPipeline;
}
export {};
| |