π¦ΈββοΈ Aggregation options
info
Extra activity, do it if you have extra time or are following at home, won't be covered during the hands-on Lab
danger
The following syntax doesn't work in the Atlas UI aggregations editor.
We can pass a document to aggregate
with some options.
let options = {
maxTimeMS: 100
};
db.authors.aggregate([], options);
π» Have a look at the different options you can pass to the aggregate method.
π» Try to launch an itcount
(a long operation) to iterate through the whole books cursor with a time limit of 10 ms: you should see the operation timing out and failing.
let options = {
maxTimeMS: 10
};
db.authors.aggregate([], options).itcount();
> MongoServerError: operation exceeded time limit