Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

SDK database Aggregate Index


May 20, 2021 WeChat Mini Program Development Document


Table of contents


Aggregate

An aggregated operation instance of a database collection

Method

Aggregate.addFields(object: Object): Aggregate

The aggregation phase. A dd a new field to the output record. After the addFields aggregation phase, all records output will have fields specified by addFields in addition to the fields that were entered.

Aggregate.bucket(object: Object): Aggregate

The aggregation phase. The input records are divided into different groups based on a given condition and boundary, one bucket for each group.

Aggregate.bucketAuto(object: Object): Aggregate

The aggregation phase. T he input records are grouped into different groups based on a given condition, one bucket for each group. One of the differences with buckets is that you don't need to specify boundaries, and bucketAuto automatically tries to spread records as evenly as possible across each group.

Aggregate.count(fieldName: string): Aggregate

The aggregation phase. Calculates the number of records entered into this stage by the previous aggregation stage and outputs a record where the value of the specified field is the number of records.

Aggregate.end(): Promise<Object>

Flag aggregation operation definition is complete, initiate the actual aggregation operation

Aggregate.geoNear(options: Object): Aggregate

The aggregation phase. The record is output from close to far from a given point.

Aggregate.group(object: Object): Aggregate

The aggregation phase. G roup input records by a given expression, and each record represents a group at output, and the _id for each record is key that distinguishes between different groups. Cumulative values can also be included in the output record, and setting the output field to cumulative values calculates cumulative values from that grouping.

Aggregate.limit(value: number): Aggregate

Polymerization phase.Limit the number of records output to the next stage.

Aggregate.lookup(object: Object): Aggregate

Polymerization phase.Polymerization phase.Dedian query.Do Left Outer Join (left an external connection) with a specified collection under the same database.Each input record of this phase is recorded in this record, which is a list of records that satisfy the matching conditions in the lapse.LOOKUP will output the result of the connection to the next stage.

Aggregate.match(object: Object): Aggregate

Polymerization phase.The document is filtered according to the conditions, and the eligible document is passed to the next pipeline stage.

Aggregate.project(object: Object): Aggregate

Polymerization phase.Pass the specified field to the next pipeline, the specified field can be a certain field, or a new field of the calculated field.

Aggregate.replaceRoot(object: Object): Aggregate

Polymerization phase.Specifies a root node that existing fields as the output, or you can specify a calculated new field as a root node.

Aggregate.sample(size: number): Aggregate

Polymerization phase.The specified number of records are randomly selected from the document.

Aggregate.skip(value: number): Aggregate

Polymerization phase.Specify a positive integer, skip the corresponding number of documents, and output the remaining documentation.

Aggregate.sort(object: Object): Aggregate

The aggregation phase. Sort the entered documents according to the specified fields.

Aggregate.sortByCount(object: Object): Aggregate

The aggregation phase. G roups of incoming collections based on incoming expressions. The number of different groups is then calculated, and the groups are sorted by the number of them, returning the results of the sort.

Aggregate.unwind(value: string|object): Aggregate

The aggregation phase. S plit the document using each element in the specified array field. When split, the document changes from one to one or more, corresponding to each element of the array.