MCPcopy
hub / github.com/mongodb/node-mongodb-native / aggregate

Method aggregate

src/collection.ts:1058–1074  ·  view source on GitHub ↗

* Execute an aggregation framework pipeline against the collection, needs MongoDB \>= 2.2 * * @param pipeline - An array of aggregation pipelines to execute * @param options - Optional settings for the command

(
    pipeline: Document[] = [],
    options?: AggregateOptions & Abortable
  )

Source from the content-addressed store, hash-verified

1056 * @param options - Optional settings for the command
1057 */
1058 aggregate<T extends Document = Document>(
1059 pipeline: Document[] = [],
1060 options?: AggregateOptions & Abortable
1061 ): AggregationCursor<T> {
1062 if (!Array.isArray(pipeline)) {
1063 throw new MongoInvalidArgumentError(
1064 'Argument "pipeline" must be an array of aggregation stages'
1065 );
1066 }
1067
1068 return new AggregationCursor(
1069 this.client,
1070 this.s.namespace,
1071 pipeline,
1072 resolveOptions(this, options)
1073 );
1074 }
1075
1076 /**
1077 * Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection.

Callers 1

countDocumentsMethod · 0.95

Calls 1

resolveOptionsFunction · 0.90

Tested by

no test coverage detected