Understanding the aggregate() Method

The Collection object provides the aggregate() method to perform aggregation operations on data. The syntax for the aggregate() method is shown below:

aggregate(operators, [options], callback)

The operators parameter is an array of aggregation operators, shown in Table 15.3, that allows you to define what aggregation operation to perform on the data. The options parameter allows you to set the readPreference property, which defines where to read the data from. The callback parameter is a function that accepts an error as the first parameter and a results array as the second parameter. The results parameter is a fully aggregated object set return by the aggregation.

Image

Table 15.3 Aggregation operators that can be used in the aggregate() method

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.124.177