Skip to main content

Supported Commands

Hint

This article is generated by AI translation.

jdbc-mongo parses raw Command instructions and converts them to underlying API calls. Below is the list of supported commands.

Command Enhancement

Regarding the db. prefix enhancement for raw MongoDB commands:

  • You can omit the db. prefix and use the collection name directly, e.g., coll1.find() queries the coll1 collection in the current database.
  • You can use <databaseName>.<collectionName>. to specify the exact collection, e.g., myDb.coll1.find() queries the coll1 collection in the myDb database.
  • You can use use databaseName to switch the current database.

Collection Operations

CommandDescriptionOfficial Docs
findQuery documents, supports limit, skip, sort, explain, hintfind
findOneQuery a single documentfindOne
insertInsert documentsinsert
insertOneInsert a single documentinsertOne
insertManyInsert multiple documentsinsertMany
updateUpdate documentsupdate
updateOneUpdate a single documentupdateOne
updateManyUpdate multiple documentsupdateMany
replaceOneReplace a single documentreplaceOne
removeDelete documentsdelete
deleteOneDelete a single documentdeleteOne
deleteManyDelete multiple documentsdeleteMany
countCount documentscount
distinctGet distinct valuesdistinct
aggregateAggregation operationsaggregate
bulkWriteBulk write operationsbulkWrite
renameCollectionRename collectionrenameCollection
dropDrop collectiondrop

Database Management

CommandDescriptionOfficial Docs
createCollectionCreate collectioncreate
createViewCreate viewcreateView
dropDatabaseDrop current databasedropDatabase
getCollectionNamesGet collection name listlistCollections
getCollectionInfosGet collection infolistCollections
runCommandRun arbitrary database commandrunCommand
serverStatusGet server statusserverStatus
statsGet database statisticsdbStats
versionGet server versionbuildInfo

Index Management

CommandDescriptionOfficial Docs
createIndexCreate indexcreateIndexes
dropIndexDrop indexdropIndexes
getIndexesGet index listlistIndexes

User Management

CommandDescriptionOfficial Docs
createUserCreate usercreateUser
dropUserDrop userdropUser
updateUserUpdate userupdateUser
changeUserPasswordChange user passwordupdateUser
grantRolesToUserGrant roles to usergrantRolesToUser
revokeRolesFromUserRevoke roles from userrevokeRolesFromUser

Other Commands

  • use <database>: Switch current database.
  • show dbs: Show all databases.
  • show collections: Show all collections in the current database.
  • show tables: Same as show collections.

Hint Support

jdbc-mongo supports overriding or enhancing query behavior through SQL Hints. The Hint format is /*+ hint_name=value */ and must be placed at the beginning of the SQL statement.

Hint NameDescriptionExample
overwrite_find_limitOverride the query's limit parameter for pagination or limiting returned rows./*+ overwrite_find_limit=10 */ db.collection.find({})
overwrite_find_skipOverride the query's skip parameter to skip a specified number of rows for pagination./*+ overwrite_find_skip=20 */ db.collection.find({})
overwrite_find_as_countConvert the query to a Count operation, ignoring returned document content and returning only the match count./*+ overwrite_find_as_count */ db.collection.find({})