Complete the code to limit the results to 5 documents.
db.collection.aggregate([{ $limit: [1] }])The $limit stage restricts the number of documents passed to the next stage. Using 5 returns only the first 5 documents.
Complete the code to skip the first 3 documents in the aggregation.
db.collection.aggregate([{ $skip: [1] }])The $skip stage skips the first N documents. Using 3 skips the first three documents and returns the rest.
Fix the error in the aggregation pipeline to correctly skip 2 documents.
db.collection.aggregate([{ $skip: [1] }])The $skip stage requires a non-negative integer. Using the number 2 correctly skips two documents. Using a string or negative number causes errors.
Fill both blanks to skip the first 4 documents and then limit the results to 3 documents.
db.collection.aggregate([{ $skip: [1] }, { $limit: [2] }])First, $skip: 4 skips the first four documents. Then, $limit: 3 limits the output to the next three documents.
Fill all three blanks to skip 2 documents, limit to 4 documents, and then skip 1 more document.
db.collection.aggregate([{ $skip: [1] }, { $limit: [2] }, { $skip: [3] }])The pipeline first skips 2 documents, then limits the output to 4 documents, and finally skips 1 document from those 4, resulting in documents 4 to 6 from the original collection.