Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions lib/aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1139,24 +1139,15 @@ Aggregate.prototype.finally = function(onFinally) {
* console.log(doc.name);
* }
*
* Node.js 10.x supports async iterators natively without any flags. You can
* enable async iterators in Node.js 8.x using the [`--harmony_async_iteration` flag](https://github.com/tc39/proposal-async-iteration/issues/117#issuecomment-346695187).
*
* **Note:** This function is not set if `Symbol.asyncIterator` is undefined. If
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
* support async iterators.
*
* @method [Symbol.asyncIterator]
* @memberOf Aggregate
* @instance
* @api public
*/

if (Symbol.asyncIterator != null) {
Aggregate.prototype[Symbol.asyncIterator] = function() {
return this.cursor({ useMongooseAggCursor: true }).transformNull()._transformForAsyncIterator();
};
}
Aggregate.prototype[Symbol.asyncIterator] = function() {
return this.cursor({ useMongooseAggCursor: true }).transformNull()._transformForAsyncIterator();
};

/*!
* Helpers
Expand Down
19 changes: 5 additions & 14 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -5406,26 +5406,17 @@ Query.prototype.nearSphere = function() {
* console.log(doc.name);
* }
*
* Node.js 10.x supports async iterators natively without any flags. You can
* enable async iterators in Node.js 8.x using the [`--harmony_async_iteration` flag](https://github.com/tc39/proposal-async-iteration/issues/117#issuecomment-346695187).
*
* **Note:** This function is not if `Symbol.asyncIterator` is undefined. If
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
* support async iterators.
*
* @method [Symbol.asyncIterator]
* @memberOf Query
* @instance
* @api public
*/

if (Symbol.asyncIterator != null) {
Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {
// Set so QueryCursor knows it should transform results for async iterators into `{ value, done }` syntax
this._mongooseOptions._asyncIterator = true;
return this.cursor();
};
}
Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {
// Set so QueryCursor knows it should transform results for async iterators into `{ value, done }` syntax
this._mongooseOptions._asyncIterator = true;
return this.cursor();
};

/**
* Specifies a `$polygon` condition
Expand Down