Database commands

HCL OneDB™ 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
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 for 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
find Yes Yes
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
getMore Yes Yes
getPrevError No No
insert Yes Yes
resetError No No
update Yes Yes

Database operations

Authentication commands
Table 4. Authentication commands
Name Supported Details
authenticate Yes
logout Yes
getnonce Yes
User management commands
Table 5. User management commands
Name Supported Details
createUser Yes
dropAllUsersFromDatabase Yes
dropUser Yes
grantRolesToUser Yes
revokeRolesFromUser Yes
updateUser Yes
usersInfo Yes
Role management commands
Table 6. Role management commands
Name Supported Details
createRole Yes
dropAllRolesFromDatabase Yes
dropRole Yes
grantPrivilegesToRole Yes
grantRolesToRole Yes
invalidateUserCache No
rolesInfo Yes
revokePrivilegesFromRole Yes
revokeRolesFromRole Yes
updateRole Yes
Diagnostic commands
Table 7. Diagnostic commands
Name Supported Details
buildInfo Yes

Whenever possible, the HCL OneDB output fields are identical to MongoDB. There are additional fields that are unique to HCL OneDB.

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 HCL OneDB 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.

1  sizeStrategy:
2.2.1! estimate
2.2.1 { estimate:n}
2.2.1 compute
2.2.1 none
2.2.1 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
HCL OneDB does not support the following flags:
  • capped
  • autoIndexID
  • size
  • max
createIndexes Yes Yes
drop Yes Yes

HCL OneDB 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
killCursors Yes Yes
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 HCL OneDB, 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 HCL OneDB 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 HCL OneDB and therefore this command has no affect for HCL OneDB.

flushRouterConfig No No

isdbgrid Yes Yes

listShards Yes Yes

The equivalent HCL OneDB command is cdr list server.

movePrimary No No
removeShard No No
shardCollection Yes Yes

The equivalent HCL OneDB 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/.