ADB - Lab Sheet 3
ADB - Lab Sheet 3
Comments in MongoDB
Hint() in MongoDB
Explanation:
In the first query, Find() method is used to find the document with a
value lesser than 25, and the max() method specifies the upper
limit of 20 hence the documents below the upper limit that satisfy the
condition are returned.
In the second query, Find() method is used to find the document with
value greater than 10 and min() method specify the lower limit to 5 hence
the document above the lower limit that satisfy the condition are returned.
5. $maxTimeMS in MongoDB
$maxTimeMS is used to specify the maximum time in which the query should
be executed. $maxTimeMS operator is deprecated instead of maxTimeMs() is
used. Time is specified in millisecond with integral value and it should be in
the range of [0 , 2147483647].
Syntax:
db.collection_name.find().maxTimeMs(mention maximum time);
Example : Use maxTimeMS() method
Query:
db.Digits.find().maxTimeMS(100);
Output:
maxTimeMs() in mongoDB
sort() in MongoDB
Explanation: The output contains the documents in the
descending order.sort() method is used to sort the documents. As field is
specified with -1 ,documents are displayed in descending order.
Conclusion
Query modifier are used to modify the query behaviour. They are used to shape
the result, improve performance, and efficiently retrieve database documents.
They are also used in sorting, projecting, limiting, and in many more
operations. They are also used to efficiently utilize the resource, increase the
readability of the query, and make developers comfortable with the task.By
considering the syntax and advantages of the query modifers ,developers can
use them to improve performance and functionality.