π¦ΈββοΈ Aggregation options
info
Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab.
danger
The following syntax doesn't work in the Atlas UI aggregations editor. The editor doesn't support declaring variables. You can try this using the built-in MongoDB Shell in MongoDB Compass.
We can pass a document to aggregate
with some options.
- MongoDB Shell
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.
- MongoDB Shell
let options = {
maxTimeMS: 10
};
db.authors.aggregate([], options).itcount();
> MongoServerError: operation exceeded time limit