A Vert.x service used to interact with MongoDB server instances.
Some of the operations might change _id field of passed document.
Constructor and description |
---|
MongoClient
(java.lang.Object delegate) |
Type | Name and description |
---|---|
void |
close() Close the client and release its resources |
MongoClient |
count(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler) Count matching documents in a collection. |
MongoClient |
createCollection(java.lang.String collectionName, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Create a new collection |
static MongoClient |
createNonShared(Vertx vertx, java.util.Map<java.lang.String, java.lang.Object> config) Create a Mongo client which maintains its own data source. |
static MongoClient |
createShared(Vertx vertx, java.util.Map<java.lang.String, java.lang.Object> config, java.lang.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, java.util.Map<java.lang.String, java.lang.Object> config) Like MongoClient.createShared but with the default data source name |
MongoClient |
distinct(java.lang.String collection, java.lang.String fieldName, java.lang.String resultClassname, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Object>>> resultHandler) Gets the distinct values of the specified field name. |
MongoClient |
distinctBatch(java.lang.String collection, java.lang.String fieldName, java.lang.String resultClassname, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Gets the distinct values of the specified field name. |
MongoClient |
dropCollection(java.lang.String collection, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Drop a collection |
MongoClient |
find(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.util.Map<java.lang.String, java.lang.Object>>>> resultHandler) Find matching documents in the specified collection |
MongoClient |
findBatch(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Find matching documents in the specified collection. |
MongoClient |
findBatchWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Find matching documents in the specified collection, specifying options. |
MongoClient |
findOne(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> fields, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Find a single matching document in the specified collection |
MongoClient |
findWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.util.Map<java.lang.String, java.lang.Object>>>> resultHandler) Find matching documents in the specified collection, specifying options |
MongoClient |
getCollections(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.String>>> resultHandler) Get a list of all collections in the database. |
java.lang.Object |
getDelegate() |
MongoClient |
insert(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> document, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler) Insert a document in the specified collection |
MongoClient |
insertWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> document, io.vertx.ext.mongo.WriteOption writeOption, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler) Insert a document in the specified collection with the specified write option |
MongoClient |
remove(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Remove matching documents from a collection |
MongoClient |
removeDocument(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Remove a single matching document from a collection and return the handler with MongoClientDeleteResult result |
MongoClient |
removeDocumentWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.ext.mongo.WriteOption writeOption, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Remove a single matching document from a collection with the specified write option and return the handler with MongoClientDeleteResult result |
MongoClient |
removeDocuments(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Remove matching documents from a collection and return the handler with MongoClientDeleteResult result |
MongoClient |
removeDocumentsWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.ext.mongo.WriteOption writeOption, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Remove matching documents from a collection with the specified write option and return the handler with MongoClientDeleteResult result |
MongoClient |
removeOne(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Remove a single matching document from a collection |
MongoClient |
removeOneWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.ext.mongo.WriteOption writeOption, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Remove a single matching document from a collection with the specified write option |
MongoClient |
removeWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, io.vertx.ext.mongo.WriteOption writeOption, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Remove matching documents from a collection with the specified write option |
MongoClient |
replace(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> replace, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Replace matching documents in the specified collection |
MongoClient |
replaceDocuments(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> replace, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Replace matching documents in the specified collection and return the handler with MongoClientUpdateResult result |
MongoClient |
replaceDocumentsWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> replace, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Replace matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result |
MongoClient |
replaceWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> replace, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Replace matching documents in the specified collection, specifying options |
MongoClient |
runCommand(java.lang.String commandName, java.util.Map<java.lang.String, java.lang.Object> command, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Run an arbitrary MongoDB command. |
MongoClient |
save(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> document, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler) Save a document in the specified collection |
MongoClient |
saveWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> document, io.vertx.ext.mongo.WriteOption writeOption, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler) Save a document in the specified collection with the specified write option |
MongoClient |
update(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> update, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Update matching documents in the specified collection |
MongoClient |
updateCollection(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> update, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Update matching documents in the specified collection and return the handler with MongoClientUpdateResult result |
MongoClient |
updateCollectionWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> update, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler) Update matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result |
MongoClient |
updateWithOptions(java.lang.String collection, java.util.Map<java.lang.String, java.lang.Object> query, java.util.Map<java.lang.String, java.lang.Object> update, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) Update matching documents in the specified collection, specifying options |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
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 configurationGets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])
collection
- the collectionfieldName
- the field nameresultHandler
- will be provided with array of values.Gets the distinct values of the specified field name. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).
collection
- the collectionfieldName
- the field nameresultHandler
- will be provided with each found valueDrop 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 matching documents in the specified collection. This method use batchCursor for returning each found document.
collection
- the collectionquery
- query used to match documentsresultHandler
- will be provided with each found documentFind matching documents in the specified collection, specifying options. This method use batchCursor for returning each found document.
collection
- the collectionquery
- query used to match documentsoptions
- options to configure the find (see FindOptions)resultHandler
- will be provided with each found documentFind a single matching document in the specified collection
This operation might change _id field of query parameter
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
This operation might change _id field of document parameter
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
This operation might change _id field of document parameter
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 and return the handler with MongoClientDeleteResult result
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 and return the handler with MongoClientDeleteResult result
collection
- the collectionquery
- query used to match documentwriteOption
- the write option to useresultHandler
- will be called when completeRemove matching documents from a collection and return the handler with MongoClientDeleteResult result
collection
- the collectionquery
- query used to match documentsresultHandler
- will be called when completeRemove matching documents from a collection with the specified write option and return the handler with MongoClientDeleteResult result
collection
- the collectionquery
- query used to match documentswriteOption
- the write option to useresultHandler
- 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
This operation might change _id field of replace parameter
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 and return the handler with MongoClientUpdateResult result
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 and return the handler with MongoClientUpdateResult result
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 completeReplace matching documents in the specified collection, specifying options
This operation might change _id field of replace parameter
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
This operation might change _id field of document parameter
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
This operation might change _id field of document parameter
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 and return the handler with MongoClientUpdateResult result
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 and return the handler with MongoClientUpdateResult result
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 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 complete