Find (en.)

The find-query is based on the syntax of the MongoDB JavaScript driver (http://mongodb.github.io/node-mongodb-native/api-generated/collection.html#find). At least one query object is required. Optionally you can also specify an options object.

{query}[, {options}]

A special feature of Mongo Management Studio is to enter the queries as quickly and easily as possible. The following example queries refer to the zipcode collection from the Getting started tutorial.

// Search all cities in the U.S. State of California. (CA) // all the following queries return the same result   // standard MongoDB query {state: "CA"}   // If there is no options object, the curly braces can be omitted state: "CA"   // You can also write everything in quotation marks "state": "CA"   // Or use single quotes state: 'CA'

MongoDB queries always distinguishes between upper and lowercase. To work around this, you can use Regular Expressions.



Of course it is possible to make more complex queries in this manner.

//Find all cities in the U.S. State of Alabama(AL) with more than 40,000 inhabitants   // standard MongoDB query { state: "AL", pop: { $gt: 40000 } }   // shortened query state: "AL", pop: {$gt: 40000}   // shortened query without whitespaces state:"AL",pop:{$gt:40000}

Using options

When using an options object curly brackets must be used in the query object.

If you want to use "$elemMatch" with ObjectIds or ISODates in the options (see example), you must use the console mode.

Special data types

ObjectId

The following queries will each return the same result if you are looking for a specific ObjectId

Date values

Date values must be entered in a specific syntax because they can´t be converted automatically.

Regex as a data field value assignment

If a field of a document has a value with a regex expression, you  can this query as follows.

Regex queries for fields with strings

You can also use regex to query fields.