mirror of
https://github.com/vale981/grapher
synced 2025-03-04 17:11:38 -05:00
15 lines
517 B
JavaScript
15 lines
517 B
JavaScript
import { Promise } from 'meteor/promise';
|
|
|
|
Mongo.Collection.prototype.aggregate = function(pipelines, options = {}) {
|
|
const coll = this.rawCollection();
|
|
|
|
let result = Meteor.wrapAsync(coll.aggregate, coll)(pipelines, options);
|
|
|
|
// We need to check If it's an AggregationCursor
|
|
// The reason we do this was because of the upgrade to 1.7 which involved a mongodb driver update
|
|
if (Array.isArray(result)) {
|
|
return result;
|
|
} else {
|
|
return Promise.await(result.toArray());
|
|
}
|
|
};
|