Javatpoint Logo
Javatpoint Logo

Query Modifiers

We have number of meta operation in addition to the MongoDB Query Operators to modify the output or behaviour of a query.

Modifiers

$comment

The comment operator makes it possible to add a comment to a query in any context.

Syntax:

$explain

The 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:

$hint

This 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:

$max

The 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:

$maxTimeMS

It is also deprecated since v3.2. It defines a cumulative time in ms for processing operations on the cursor.

Syntax:

$min

The 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:

$orderby

The orderby operator arranges the results of a query in ascending or descending order.

Syntax:

$query

It forcefully interprets an expression as a query using MongoDB.

Syntax:

$returnKey

The 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:

$showDiskLoc

The 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:

$natural

The natural operator is a special sort order operator that arranges the documents using the order of documents on disk using the cursor.hint ().






Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA