You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Performs an aggregate() query on a passed-in Mongo collection, using criteria you specify.
21
+
* Unlike `find()`, this method requires fine tuning by the user, and must comply with the following
22
+
* two criteria so that the pagination magic can work properly.
23
+
*
24
+
* 1. `aggregate()` will insert a `$sort` and `$limit` clauses in your aggregation pipeline immediately after
25
+
* the first $match is found. Consider this while building your pipeline.
26
+
*
27
+
* 2. The documents resulting from the aggregation _must_ contain the paginated fields so that a
28
+
* cursor can be built from the result set.
29
+
*
30
+
* Additionally, an additional query will be appended to the first `$match` found in order to apply the offset
31
+
* required for the cursor.
32
+
*
33
+
* @param {MongoCollection} collection A collection object returned from the MongoDB library's
34
+
* or the mongoist package's `db.collection(<collectionName>)` method.
35
+
* @param {Object} params
36
+
* -aggregation {Object[]} The aggregation query.
37
+
* -limit {Number} The page size. Must be between 1 and `config.MAX_LIMIT`.
38
+
* -paginatedField {String} The field name to query the range for. The field must be:
39
+
* 1. Orderable. We must sort by this value. If duplicate values for paginatedField field
40
+
* exist, the results will be secondarily ordered by the _id.
41
+
* 2. Immutable. If the value changes between paged queries, it could appear twice.
42
+
* 3. Accessible. The field must be present in the aggregation's end result so the
43
+
* aggregation steps added at the end of the pipeline to implement the paging can access it.
44
+
4. Consistent. All values (except undefined and null values) must be of the same type.
45
+
* The default is to use the Mongo built-in '_id' field, which satisfies the above criteria.
46
+
* The only reason to NOT use the Mongo _id field is if you chose to implement your own ids.
47
+
* -sortAscending {boolean} Whether to sort in ascending order by the `paginatedField`.
48
+
* -sortCaseInsensitive {boolean} Whether to ignore case when sorting, in which case `paginatedField`
49
+
* must be a string property.
50
+
* -next {String} The value to start querying the page.
51
+
* -previous {String} The value to start querying previous page.
52
+
* -after {String} The _id to start querying the page.
53
+
* -before {String} The _id to start querying previous page.
54
+
* -options {Object} Aggregation options
55
+
* -collation {Object} An optional collation to provide to the mongo query. E.g. { locale: 'en', strength: 2 }. When null, disables the global collation.
* Performs a find() query on a passed-in Mongo collection, using criteria you specify. The results
16
+
* are ordered by the paginatedField.
17
+
*
18
+
* @param {MongoCollection} collection A collection object returned from the MongoDB library's
19
+
* or the mongoist package's `db.collection(<collectionName>)` method.
20
+
* @param {Object} params
21
+
* -query {Object} The find query.
22
+
* -limit {Number} The page size. Must be between 1 and `config.MAX_LIMIT`.
23
+
* -fields {Object} Fields to query in the Mongo object format, e.g. {_id: 1, timestamp :1}.
24
+
* The default is to query all fields.
25
+
* -paginatedField {String} The field name to query the range for. The field must be:
26
+
* 1. Orderable. We must sort by this value. If duplicate values for paginatedField field
27
+
* exist, the results will be secondarily ordered by the _id.
28
+
* 2. Indexed. For large collections, this should be indexed for query performance.
29
+
* 3. Immutable. If the value changes between paged queries, it could appear twice.
30
+
4. Consistent. All values (except undefined and null values) must be of the same type.
31
+
* The default is to use the Mongo built-in '_id' field, which satisfies the above criteria.
32
+
* The only reason to NOT use the Mongo _id field is if you chose to implement your own ids.
33
+
* -sortAscending {boolean} Whether to sort in ascending order by the `paginatedField`.
34
+
* -sortCaseInsensitive {boolean} Whether to ignore case when sorting, in which case `paginatedField`
35
+
* must be a string property.
36
+
* -next {String} The value to start querying the page.
37
+
* -previous {String} The value to start querying previous page.
38
+
* -after {String} The _id to start querying the page.
39
+
* -before {String} The _id to start querying previous page.
40
+
* -hint {String} An optional index hint to provide to the mongo query
41
+
* -collation {Object} An optional collation to provide to the mongo query. E.g. { locale: 'en', strength: 2 }. When null, disables the global collation.
0 commit comments