'use strict';

var _ = require('underscore');
var SourceCollection = require('mongodb').Collection;

module.exports = function(Collection) {
	Collection.prototype.aggregate = function(pipeline, options) {
		options = _({}).defaults(
			options,
			{cursor: {}}
		);

		return SourceCollection.prototype.aggregate.call(this, pipeline, options);
	};
};

'use strict';

var SourceCollection = require('mongodb').Collection;
var utils = require('../utils');

module.exports = function(Collection) {
	Collection.prototype.aggregate = function(pipeline, options) {
		if (options) {
			options = utils.deepExtend(
				{cursor: {}},
				options
			);
		}

		return SourceCollection.prototype.aggregate.call(this, pipeline, options);
	};
};

use local utils instead of underscore