Accessing Data : Accessing MongoDB data : Specifying the data to retrieve from MongoDB : Writing expressions
 
Writing expressions
When you create a MongoDB data set query, you can create Mongo JSON expressions for the following:
*Run Database commands
*Aggregate commands
*MapReduce commands
*Query expressions
*Sort expressions
You can type the expression or import it from a text file. You can then validate the syntax of the expression. You can override an expression at runtime by setting the appropriate property or properties on the Property Binding page in the Data Set Editor. Embedded input parameter markers are not supported.
Writing expressions for Run Database commands
Run Database Command executes a MongoDB command-driven query. The command result document is exposed as available fields that can be selected and bound to a data set’s columns. These commands are run on the connected database; any specified MongoDB collection is ignored.
Run Database Command supports read-only operation. The following MongoDB database commands are supported.
*buildInfo
*collStats
*connPoolStats
*count
*cursorInfo
*dataSize
*dbStats
*distinct
*eval with nolock: true *
*geoNear
*geoSearch
*getLastError
*getLog
*getPrevError
*group
*isMaster
*isdbgrid
*listCommands
*listDatabases
*listShards
*ping
*printShardingStatus
*replSetGetStatus
*serverStatus
* eval with nolock: true is used to evaluate a function written in JavaScript at the database server. eval’s default behavior of taking a global write lock is not allowed.
For more information about MongoDB database commands, see
http://docs.mongodb.org/manual/reference/command/
Writing expressions for Aggregate commands
When writing expressions for Aggregate commands, including array markers at the beginning and end of a pipeline expression is optional. A sort value must be 1 or -1.
For more information about Aggregate commands, see
http://docs.mongodb.org/manual/reference/aggregation/
For Aggregation Framework examples, see
http://docs.mongodb.org/manual/tutorial/aggregation-examples/
Writing query expressions
A query expression is optional, and is only applicable to a data set that has either a FindQuery or MapReduce (with output to a collection) command operation. You must specify a MongoDB JSON expression to describe a custom $query operation to filter on the specified collection, or an output collection returned by the MapReduce command. A query expression is ignored when a MapReduce command outputs to inline using the syntax out: { inline: 1 }. In this case, you must specify the query parameters directly in the MapReduce command expression.
For more information about query expressions and examples, see
http://docs.mongodb.org/manual/reference/operator/query/
Writing sort expressions
A sort expression is optional, and is only applicable to a data set that has either a FindQuery or MapReduce (with output to a collection) command operation. You must specify a MongoDB JSON expression to describe a custom sort operation on the result cursor. A sort value can be a positive value (>= 0 or true/false) for ascending order, or a negative value for descending order. Take note of the following:
*If Flatten nested collections is enabled, a sort expression is applied to the result set before rows are flattened.
*A sort expression is ignored when a MapReduce command outputs to inline using the syntax out: { inline: 1 }. In this case, you must specify the sort parameters directly in the MapReduce command expression.
*Make sure that an index exists on the sort attribute, or set a runtime limit on maxRows.
For more information about sort expressions and examples, see
http://docs.mongodb.org/manual/reference/method/cursor.sort/#cursor.sort