Database commands

Informix® supports a subset of the MongoDB database commands.

The basic syntax for database commands in the mongo shell is db.command(), where db refers to the current database, and command is the database command. You can use the mongo shell helper method db.runCommand() to run database commands on the current database.

User commands

Aggregation commands
Table 1. Aggregation commands
MongoDB command JSON collections Relational tables Details
aggregate Yes Yes The wire listener supports version 2.4 of the MongoDB aggregate command, which returns a command result. For more information, see Aggregation framework operators.
count Yes Yes
distinct Yes Yes
group No No
mapReduce No No
Geospatial commands
Table 2. Geospatial commands
MongoDB command JSON collections Relational tables Details
geoNear Yes No Supported by using the GeoJSON format. The MongoDB legacy coordinate pairs are not supported.
geoSearch No No
geoWalk No No
Query and write operation commands
Table 3. Query and write operation commands
MongoDB command JSON collections Relational tables Details
delete Yes Yes
eval No No
findAndModify Yes Yes For relational tables, the findAndModify command is supported only for tables that have a primary key. This command does not support sharded data.
getLastError Yes Yes
getPrevError No No
insert Yes Yes
resetError No No
text No No Text queries are supported by using the $text or $ifxtext query operators, not through the text command.
update Yes Yes

Database operations

Authentication commands
Table 4. Authentication commands
Name Supported Details
authenticate Yes
authSchemaUpgrade Yes This command upgrades user data to MongoDB API version 2.6 or higher.
logout Yes
getnonce Yes
User management commands
Table 5. User management commands
Name Supported Details
createUser Yes Supported for MongoDB API version 2.6 or higher.
dropAllUsersFromDatabase Yes Supported for MongoDB API version 2.6 or higher.
dropUser Yes Supported for MongoDB API version 2.6 or higher.
grantRolesToUser Yes Supported for MongoDB API version 2.6 or higher.
revokeRolesFromUser Yes Supported for MongoDB API version 2.6 or higher.
updateUser Yes Supported for MongoDB API version 2.6 or higher.
usersInfo Yes Supported for MongoDB API version 2.6 or higher.
Role management commands
Table 6. Role management commands
Name Supported Details
createRole Yes Supported for MongoDB API version 2.6 or higher.
dropAllRolesFromDatabase Yes Supported for MongoDB API version 2.6 or higher.
dropRole Yes Supported for MongoDB API version 2.6 or higher.
grantPrivilegesToRole Yes Supported for MongoDB API version 2.6 or higher.
grantRolesToRole Yes Supported for MongoDB API version 2.6 or higher.
invalidateUserCache No
rolesInfo Yes Supported for MongoDB API version 2.6 or higher.
revokePrivilegesFromRole Yes Supported for MongoDB API version 2.6 or higher.
revokeRolesFromRole Yes Supported for MongoDB API version 2.6 or higher.
updateRole Yes Supported for MongoDB API version 2.6 or higher.
Diagnostic commands
Table 7. Diagnostic commands
Name Supported Details
buildInfo Yes

Whenever possible, the Informix® output fields are identical to MongoDB. There are additional fields that are unique to Informix®.

collStats Yes

The value of any field that is based on the collection size is an estimate, not an exact value. For example, the value of the field 'size' is an estimate.

connPoolStats No

cursorInfo No

dbStats Yes

The value of any field that is based on the collection size is an estimate, not an exact value. For example, the value of the field 'dataSize' is an estimate.

features Yes
getCmdLineOpts Yes
getLog No
hostInfo Yes

The memSizeMB, totalMemory, and freeMemory fields indicate the amount of memory that is available to the Java virtual machine (JVM) that is running, not the operating system values.

indexStats No
listCommands Yes
listDatabases Yes

The value of any field that is based on the collection size is an estimate, not an exact value. For example, the value of the field 'sizeOnDisk' is an estimate.

The listDatabases command estimates the size of all collections and collection indexes for each database. However, relational tables and indexes are excluded from this size calculation.

Important: The listDatabases command performs expensive and CPU-intensive computations on the size of each database in the Informix® instance. You can decrease the expense by using the sizeStrategy option.
sizeStrategy
You can use this option to configure the strategy for calculating database size when the listDatabases command is run.
sizeStrategy: { { estimate | { estimate:n} | compute | none | perDatabaseSpace } }
estimate
Estimate the size of the documents in the collection by using 1000 (or 0.1%) of the documents. This is the default value.
The following example estimates the collection size by using the default of 1000 (or 0.1%) of the documents:
db.runCommand({listDatabases:1,
 sizeStrategy:"estimate"})  
estimate: n
Estimate the size of the documents in a collection by sampling one document for every n documents in the collection.
The following example estimates the collection size by using sample size of 0.5% or 1/200th of the documents:
db.runCommand({listDatabases:1,
 sizeStrategy:{estimate:200}}) 
compute
Compute the exact size of each database.
db.runCommand({listDatabases:1,
 sizeStrategy:"compute"})
none
List the databases but do not compute the size. The database size is listed as 0.
db.runCommand({listDatabases:1,
 sizeStrategy:"none"})
perDatabaseSpace
Calculate the size of a database by adding the sizes for all dbspaces, sbspaces, and blobspaces that are assigned to the tenant database.
Important: The perDatabaseSpace option applies only to tenant databases that are created by the multi-tenancy feature.
db.runCommand({listDatabases:1 ,
 sizeStrategy:"perDatabaseSpace"})
ping Yes
serverStatus Yes
top No
whatsmyuri Yes
Instance administration commands
Table 8. Instance administration commands
Name JSON collections Relational tables Details
clone No No
cloneCollection No No
cloneCollectionAsCapped No No
collMod No No
compact No No
convertToCapped No No
copydb No No
create Yes No
Informix® does not support the following flags:
  • capped
  • autoIndexID
  • size
  • max
createIndexes Yes Yes
drop Yes Yes

Informix® does not lock the database to block concurrent activity.

dropDatabase Yes Yes

dropIndexes Yes No

The MongoDB deleteIndexes command is equivalent.

filemd5 Yes Yes
fsync No No
getParameter No No
listCollections Yes Yes The includeRelational and includeSystem flags are supported to include or exclude relational or system tables in the results.

Default is includeRelational=true and includeSystem=false.

listIndexes Yes Yes
logRotate No No
reIndex No No
renameCollection No No
repairDatabase No No
setParameter No No
shutdown Yes Yes

The timeoutSecs flag is supported. In the Informix®, the timeoutSecs flag determines the number of seconds that the wire listener waits for a busy client to stop working before forcibly terminating the session.

The force flag is not supported.

touch No No
Replication commands
Table 9. Replication commands
Name Supported
isMaster Yes
replSetFreeze No
replSetGetStatus No
replSetInitiate No
replSetMaintenance No
replSetReconfig No
replSetStepDown No
replSetSyncFrom No
Resync No
Sharding commands
Table 10. Replication commands
Name JSON collections Relational tables Details
addShard Yes Yes

The MongoDB maxSize and name options are not supported.

In addition to the MongoDB command syntax for adding a single shard server, you can use the Informix® specific syntax to add multiple shard servers in one command by sending the list of shard servers as an array. For more information, see Creating a shard cluster with MongoDB commands.

enableSharding Yes Yes

This action is not required for Informix® and therefore this command has no affect for Informix®.

flushRouterConfig No No

isdbgrid Yes Yes

listShards Yes Yes

The equivalent Informix® command is cdr list server.

movePrimary No No
removeShard No No
shardCollection Yes Yes

The equivalent Informix® command is cdr define shardCollection.

The MongoDB unique and numInitialChunks options are not supported.

shardingState No No
split No No

For more information about the MongoDB features, see http://docs.mongodb.org/manual/reference/.