Query ModifiersWe have number of meta operation in addition to the MongoDB Query Operators to modify the output or behaviour of a query. Modifiers$commentThe comment operator makes it possible to add a comment to a query in any context. Syntax: $explainThe explain modifier provides details about the query plan. It returns a file that describes the process and indexes used to return the query. It may give useful insight when attempting to optimize a query. Syntax: $hintThis operator is deprecated in the mongo shell now. The hint operator attaches the optimizer to use the declared index to fulfill the query. It is also used for testing query performance and indexing strategies. Syntax: $maxThe max operator is deprecated in mongo shell since v3.2. It defines a max value to specify the exclusive upper bound for the given index in order to limit the results of find (). Syntax: $maxTimeMSIt is also deprecated since v3.2. It defines a cumulative time in ms for processing operations on the cursor. Syntax: $minThe min operator is used to find a minimum value to declare the included lower bound for a specified index to constrain the results of find (). Syntax: $orderbyThe orderby operator arranges the results of a query in ascending or descending order. Syntax: $queryIt forcefully interprets an expression as a query using MongoDB. Syntax: $returnKeyThe return key returns the index fields for the results of the query. If returnkey operator is set to true then the returned documents will not contain any fields. Syntax: $showDiskLocThe showDiskLoc operator adds a field to the resultant documents. The value of the added diskLoc field is a document that contains the disk location details. Syntax: $naturalThe natural operator is a special sort order operator that arranges the documents using the order of documents on disk using the cursor.hint (). Next TopicAggregation Commands |