From 69bf575b7ddc194580df9096dfaf2d108e46e76c Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 3 Nov 2019 14:45:16 -0500 Subject: [PATCH] docs(aggregate): make aggregation Symbol.iterator docs actually use aggregate() Re: #8280 --- lib/aggregate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/aggregate.js b/lib/aggregate.js index a1615df41b2..b9d08af3181 100644 --- a/lib/aggregate.js +++ b/lib/aggregate.js @@ -1011,20 +1011,20 @@ Aggregate.prototype.catch = function(reject) { /** * Returns an asyncIterator for use with [`for/await/of` loops](http://bit.ly/async-iterators) - * This function *only* works for `find()` queries. * You do not need to call this function explicitly, the JavaScript runtime * will call it for you. * * ####Example * - * for await (const doc of Model.find().sort({ name: 1 })) { + * const agg = Model.aggregate([{ $match: { age: { $gte: 25 } } }]); + * for await (const doc of agg) { * 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 + * **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. *