@@ -33,6 +33,7 @@ const config = require('./config');
33
33
* -previous {String} The value to start querying previous page.
34
34
* -after {String} The _id to start querying the page.
35
35
* -before {String} The _id to start querying previous page.
36
+ * -options {Object} Aggregation options
36
37
*/
37
38
module . exports = async function aggregate ( collection , params ) {
38
39
params = _ . defaults ( await sanitizeParams ( collection , params ) , { aggregation : [ ] } ) ;
@@ -57,6 +58,10 @@ module.exports = async function aggregate(collection, params) {
57
58
params . aggregation . splice ( index + 1 , 0 , { $sort } ) ;
58
59
params . aggregation . splice ( index + 2 , 0 , { $limit : params . limit + 1 } ) ;
59
60
61
+ // Aggregation options:
62
+ // https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#aggregate
63
+ // https://mongodb.github.io/node-mongodb-native/4.0/interfaces/aggregateoptions.html
64
+ const options = params . options || { } ;
60
65
/**
61
66
* IMPORTANT
62
67
*
@@ -66,7 +71,7 @@ module.exports = async function aggregate(collection, params) {
66
71
*
67
72
* See mongo documentation: https://docs.mongodb.com/manual/reference/collation/#collation-and-index-use
68
73
*/
69
- const options = config . COLLATION ? { collation : config . COLLATION } : undefined ;
74
+ if ( config . COLLATION ) options . collation = config . COLLATION ;
70
75
71
76
// Support both the native 'mongodb' driver and 'mongoist'. See:
72
77
// https://www.npmjs.com/package/mongoist#cursor-operations
0 commit comments