Skip to content

Commit

Permalink
🐛 Make Model#aggregate(pipeline) work again
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Dec 27, 2024
1 parent c672882 commit 0dd6c5f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.4.0-alpha.9 (WIP)

* Fix `Conduit#parseRequest()` forgetting GET query parameters when overriding respone url
* Make `Model#aggregate(pipeline)` work again

## 1.4.0-alpha.8 (2024-11-28)

Expand Down
21 changes: 13 additions & 8 deletions lib/class/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,21 +679,26 @@ Model.setMethod(function disableTranslations() {
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 0.5.0
* @version 0.5.0
* @version 1.4.0
*
* @param {Array} pipeline
* @param {Function} callback
*/
Model.setMethod(function aggregate(pipeline, callback) {
Model.setMethod(async function aggregate(pipeline, callback) {

this.datasource.collection(this.table, function gotCollection(err, collection) {
let collection = await this.datasource.collection(this.table);

if (err) {
return callback(err);
}
if (err) {
return pledge.reject(err);
}

collection.aggregate(pipeline, callback);
});
let cursor = collection.aggregate(pipeline);

if (typeof callback == 'function') {
callback(null, cursor);
}

return cursor;
});

/**
Expand Down

0 comments on commit 0dd6c5f

Please sign in to comment.