A Vert.x service used to interact with MongoDB server instances.
| Constructor and description |
|---|
MongoClient
(Object delegate) |
| Type | Name and description |
|---|---|
void |
close()Close the client and release its resources |
MongoClient |
count(String collection, Map<String, Object> query, Handler<AsyncResult<Long>> resultHandler)Count matching documents in a collection. |
MongoClient |
createCollection(String collectionName, Handler<AsyncResult<Void>> resultHandler)Create a new collection |
static MongoClient |
createNonShared(Vertx vertx, Map<String, Object> config)Create a Mongo client which maintains its own data source. |
static MongoClient |
createShared(Vertx vertx, Map<String, Object> config, String dataSourceName)Create a Mongo client which shares its data source with any other Mongo clients created with the same data source name |
static MongoClient |
createShared(Vertx vertx, Map<String, Object> config)Like MongoClient.createShared but with the default data source name |
MongoClient |
dropCollection(String collection, Handler<AsyncResult<Void>> resultHandler)Drop a collection |
MongoClient |
find(String collection, Map<String, Object> query, Handler<AsyncResult<List<Map<String, Object>>>> resultHandler)Find matching documents in the specified collection |
MongoClient |
findOne(String collection, Map<String, Object> query, Map<String, Object> fields, Handler<AsyncResult<Map<String, Object>>> resultHandler)Find a single matching document in the specified collection |
MongoClient |
findWithOptions(String collection, Map<String, Object> query, Map<String, Object> options, Handler<AsyncResult<List<Map<String, Object>>>> resultHandler)Find matching documents in the specified collection, specifying options |
MongoClient |
getCollections(Handler<AsyncResult<List<String>>> resultHandler)Get a list of all collections in the database. |
Object |
getDelegate() |
MongoClient |
insert(String collection, Map<String, Object> document, Handler<AsyncResult<String>> resultHandler)Insert a document in the specified collection |
MongoClient |
insertWithOptions(String collection, Map<String, Object> document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)Insert a document in the specified collection with the specified write option |
MongoClient |
remove(String collection, Map<String, Object> query, Handler<AsyncResult<Void>> resultHandler)Remove matching documents from a collection |
MongoClient |
removeOne(String collection, Map<String, Object> query, Handler<AsyncResult<Void>> resultHandler)Remove a single matching document from a collection |
MongoClient |
removeOneWithOptions(String collection, Map<String, Object> query, WriteOption writeOption, Handler<AsyncResult<Void>> resultHandler)Remove a single matching document from a collection with the specified write option |
MongoClient |
removeWithOptions(String collection, Map<String, Object> query, WriteOption writeOption, Handler<AsyncResult<Void>> resultHandler)Remove matching documents from a collection with the specified write option |
MongoClient |
replace(String collection, Map<String, Object> query, Map<String, Object> replace, Handler<AsyncResult<Void>> resultHandler)Replace matching documents in the specified collection |
MongoClient |
replaceWithOptions(String collection, Map<String, Object> query, Map<String, Object> replace, Map<String, Object> options, Handler<AsyncResult<Void>> resultHandler)Replace matching documents in the specified collection, specifying options |
MongoClient |
runCommand(String commandName, Map<String, Object> command, Handler<AsyncResult<Map<String, Object>>> resultHandler)Run an arbitrary MongoDB command. |
MongoClient |
save(String collection, Map<String, Object> document, Handler<AsyncResult<String>> resultHandler)Save a document in the specified collection |
MongoClient |
saveWithOptions(String collection, Map<String, Object> document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)Save a document in the specified collection with the specified write option |
MongoClient |
update(String collection, Map<String, Object> query, Map<String, Object> update, Handler<AsyncResult<Void>> resultHandler)Update matching documents in the specified collection |
MongoClient |
updateWithOptions(String collection, Map<String, Object> query, Map<String, Object> update, Map<String, Object> options, Handler<AsyncResult<Void>> resultHandler)Update matching documents in the specified collection, specifying options |
Close the client and release its resources
Count matching documents in a collection.
collection - the collectionquery - query used to match documentsresultHandler - will be provided with the number of matching documentsCreate a new collection
collectionName - the name of the collectionresultHandler - will be called when completeCreate a Mongo client which maintains its own data source.
vertx - the Vert.x instanceconfig - the configurationCreate a Mongo client which shares its data source with any other Mongo clients created with the same data source name
vertx - the Vert.x instanceconfig - the configurationdataSourceName - the data source nameLike MongoClient.createShared but with the default data source name
vertx - the Vert.x instanceconfig - the configurationDrop a collection
collection - the collectionresultHandler - will be called when completeFind matching documents in the specified collection
collection - the collectionquery - query used to match documentsresultHandler - will be provided with list of documentsFind a single matching document in the specified collection
collection - the collectionquery - the query used to match the documentfields - the fieldsresultHandler - will be provided with the document, if anyFind matching documents in the specified collection, specifying options
collection - the collectionquery - query used to match documentsoptions - options to configure the find (see FindOptions)resultHandler - will be provided with list of documentsGet a list of all collections in the database.
resultHandler - will be called with a list of collections.Insert a document in the specified collection
collection - the collectiondocument - the documentresultHandler - result handler will be provided with the id if document didn't already have oneInsert a document in the specified collection with the specified write option
collection - the collectiondocument - the documentwriteOption - the write option to useresultHandler - result handler will be provided with the id if document didn't already have oneRemove matching documents from a collection
collection - the collectionquery - query used to match documentsresultHandler - will be called when completeRemove a single matching document from a collection
collection - the collectionquery - query used to match documentresultHandler - will be called when completeRemove a single matching document from a collection with the specified write option
collection - the collectionquery - query used to match documentwriteOption - the write option to useresultHandler - will be called when completeRemove matching documents from a collection with the specified write option
collection - the collectionquery - query used to match documentswriteOption - the write option to useresultHandler - will be called when completeReplace matching documents in the specified collection
collection - the collectionquery - query used to match the documentsreplace - all matching documents will be replaced with thisresultHandler - will be called when completeReplace matching documents in the specified collection, specifying options
collection - the collectionquery - query used to match the documentsreplace - all matching documents will be replaced with thisoptions - options to configure the replace (see UpdateOptions)resultHandler - will be called when completeRun an arbitrary MongoDB command.
commandName - the name of the commandcommand - the commandresultHandler - will be called with the result.Save a document in the specified collection
collection - the collectiondocument - the documentresultHandler - result handler will be provided with the id if document didn't already have oneSave a document in the specified collection with the specified write option
collection - the collectiondocument - the documentwriteOption - the write option to useresultHandler - result handler will be provided with the id if document didn't already have oneUpdate matching documents in the specified collection
collection - the collectionquery - query used to match the documentsupdate - used to describe how the documents will be updatedresultHandler - will be called when completeUpdate matching documents in the specified collection, specifying options
collection - the collectionquery - query used to match the documentsupdate - used to describe how the documents will be updatedoptions - options to configure the update (see UpdateOptions)resultHandler - will be called when completeio.vertx:vertx-mongo-client:3.1.0