public interface MongoClient
Some of the operations might change _id field of passed JsonObject
document.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DB_NAME
The name of the default database
|
static String |
DEFAULT_POOL_NAME
The name of the default pool
|
Modifier and Type | Method and Description |
---|---|
ReadStream<JsonObject> |
aggregate(String collection,
JsonArray pipeline)
Run aggregate MongoDB command with default
AggregateOptions . |
ReadStream<JsonObject> |
aggregateWithOptions(String collection,
JsonArray pipeline,
AggregateOptions options)
Run aggregate MongoDB command.
|
MongoClient |
bulkWrite(String collection,
List<BulkOperation> operations,
Handler<AsyncResult<MongoClientBulkWriteResult>> resultHandler)
Execute a bulk operation.
|
MongoClient |
bulkWriteWithOptions(String collection,
List<BulkOperation> operations,
BulkWriteOptions bulkWriteOptions,
Handler<AsyncResult<MongoClientBulkWriteResult>> resultHandler)
Execute a bulk operation with the specified write options.
|
void |
close()
Close the client and release its resources
|
MongoClient |
count(String collection,
JsonObject query,
Handler<AsyncResult<Long>> resultHandler)
Count matching documents in a collection.
|
static MongoClient |
create(Vertx vertx,
JsonObject config)
Create a Mongo client which maintains its own data source.
|
MongoClient |
createCollection(String collectionName,
Handler<AsyncResult<Void>> resultHandler)
Create a new collection
|
MongoClient |
createIndex(String collection,
JsonObject key,
Handler<AsyncResult<Void>> resultHandler)
Creates an index.
|
MongoClient |
createIndexWithOptions(String collection,
JsonObject key,
IndexOptions options,
Handler<AsyncResult<Void>> resultHandler)
Creates an index.
|
static MongoClient |
createNonShared(Vertx vertx,
JsonObject config)
Deprecated.
use
create(Vertx, JsonObject) instead |
static MongoClient |
createShared(Vertx vertx,
JsonObject config)
Like
createShared(io.vertx.core.Vertx, JsonObject, String) but with the default data source name |
static MongoClient |
createShared(Vertx vertx,
JsonObject config,
String dataSourceName)
Create a Mongo client which shares its data source with any other Mongo clients created with the same
data source name
|
MongoClient |
distinct(String collection,
String fieldName,
String resultClassname,
Handler<AsyncResult<JsonArray>> resultHandler)
Gets the distinct values of the specified field name.
|
ReadStream<JsonObject> |
distinctBatch(String collection,
String fieldName,
String resultClassname)
Gets the distinct values of the specified field name.
|
ReadStream<JsonObject> |
distinctBatchWithQuery(String collection,
String fieldName,
String resultClassname,
JsonObject query)
Gets the distinct values of the specified field name filtered by specified query.
|
ReadStream<JsonObject> |
distinctBatchWithQuery(String collection,
String fieldName,
String resultClassname,
JsonObject query,
int batchSize)
Gets the distinct values of the specified field name filtered by specified query.
|
MongoClient |
distinctWithQuery(String collection,
String fieldName,
String resultClassname,
JsonObject query,
Handler<AsyncResult<JsonArray>> resultHandler)
Gets the distinct values of the specified field name filtered by specified query.
|
MongoClient |
dropCollection(String collection,
Handler<AsyncResult<Void>> resultHandler)
Drop a collection
|
MongoClient |
dropIndex(String collection,
String indexName,
Handler<AsyncResult<Void>> resultHandler)
Drops the index given its name.
|
MongoClient |
find(String collection,
JsonObject query,
Handler<AsyncResult<List<JsonObject>>> resultHandler)
Find matching documents in the specified collection
|
ReadStream<JsonObject> |
findBatch(String collection,
JsonObject query)
Find matching documents in the specified collection.
|
ReadStream<JsonObject> |
findBatchWithOptions(String collection,
JsonObject query,
FindOptions options)
Find matching documents in the specified collection, specifying options.
|
MongoClient |
findOne(String collection,
JsonObject query,
JsonObject fields,
Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection
|
MongoClient |
findOneAndDelete(String collection,
JsonObject query,
Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and delete it.
|
MongoClient |
findOneAndDeleteWithOptions(String collection,
JsonObject query,
FindOptions findOptions,
Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and delete it.
|
MongoClient |
findOneAndReplace(String collection,
JsonObject query,
JsonObject replace,
Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and replace it.
|
MongoClient |
findOneAndReplaceWithOptions(String collection,
JsonObject query,
JsonObject replace,
FindOptions findOptions,
UpdateOptions updateOptions,
Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and replace it.
|
MongoClient |
findOneAndUpdate(String collection,
JsonObject query,
JsonObject update,
Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and update it.
|
MongoClient |
findOneAndUpdateWithOptions(String collection,
JsonObject query,
JsonObject update,
FindOptions findOptions,
UpdateOptions updateOptions,
Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and update it.
|
MongoClient |
findWithOptions(String collection,
JsonObject query,
FindOptions options,
Handler<AsyncResult<List<JsonObject>>> 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.
|
MongoClient |
insert(String collection,
JsonObject document,
Handler<AsyncResult<String>> resultHandler)
Insert a document in the specified collection
|
MongoClient |
insertWithOptions(String collection,
JsonObject document,
WriteOption writeOption,
Handler<AsyncResult<String>> resultHandler)
Insert a document in the specified collection with the specified write option
|
MongoClient |
listIndexes(String collection,
Handler<AsyncResult<JsonArray>> resultHandler)
Get all the indexes in this collection.
|
MongoClient |
remove(String collection,
JsonObject query,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
use instead
removeDocuments(String, JsonObject, Handler) |
MongoClient |
removeDocument(String collection,
JsonObject query,
Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove a single matching document from a collection and return the handler with MongoClientDeleteResult result
|
MongoClient |
removeDocuments(String collection,
JsonObject query,
Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove matching documents from a collection and return the handler with MongoClientDeleteResult result
|
MongoClient |
removeDocumentsWithOptions(String collection,
JsonObject query,
WriteOption writeOption,
Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove matching documents from a collection with the specified write option and return the handler with MongoClientDeleteResult result
|
MongoClient |
removeDocumentWithOptions(String collection,
JsonObject query,
WriteOption writeOption,
Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove a single matching document from a collection with the specified write option and return the handler with MongoClientDeleteResult result
|
MongoClient |
removeOne(String collection,
JsonObject query,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
instead use
removeDocument(String, JsonObject, Handler) |
MongoClient |
removeOneWithOptions(String collection,
JsonObject query,
WriteOption writeOption,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
|
MongoClient |
removeWithOptions(String collection,
JsonObject query,
WriteOption writeOption,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
|
MongoClient |
replace(String collection,
JsonObject query,
JsonObject replace,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
|
MongoClient |
replaceDocuments(String collection,
JsonObject query,
JsonObject replace,
Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Replace matching documents in the specified collection and return the handler with MongoClientUpdateResult result
|
MongoClient |
replaceDocumentsWithOptions(String collection,
JsonObject query,
JsonObject replace,
UpdateOptions options,
Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Replace matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result
|
MongoClient |
replaceWithOptions(String collection,
JsonObject query,
JsonObject replace,
UpdateOptions options,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
|
MongoClient |
runCommand(String commandName,
JsonObject command,
Handler<AsyncResult<JsonObject>> resultHandler)
Run an arbitrary MongoDB command.
|
MongoClient |
save(String collection,
JsonObject document,
Handler<AsyncResult<String>> resultHandler)
Save a document in the specified collection
|
MongoClient |
saveWithOptions(String collection,
JsonObject document,
WriteOption writeOption,
Handler<AsyncResult<String>> resultHandler)
Save a document in the specified collection with the specified write option
|
MongoClient |
update(String collection,
JsonObject query,
JsonObject update,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
|
MongoClient |
updateCollection(String collection,
JsonObject query,
JsonObject update,
Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Update matching documents in the specified collection and return the handler with MongoClientUpdateResult result
|
MongoClient |
updateCollectionWithOptions(String collection,
JsonObject query,
JsonObject update,
UpdateOptions options,
Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Update matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result
|
MongoClient |
updateWithOptions(String collection,
JsonObject query,
JsonObject update,
UpdateOptions options,
Handler<AsyncResult<Void>> resultHandler)
Deprecated.
|
static final String DEFAULT_POOL_NAME
static final String DEFAULT_DB_NAME
@Deprecated static MongoClient createNonShared(Vertx vertx, JsonObject config)
create(Vertx, JsonObject)
insteadstatic MongoClient create(Vertx vertx, JsonObject config)
vertx
- the Vert.x instanceconfig
- the configurationstatic MongoClient createShared(Vertx vertx, JsonObject config, String dataSourceName)
vertx
- the Vert.x instanceconfig
- the configurationdataSourceName
- the data source namestatic MongoClient createShared(Vertx vertx, JsonObject config)
createShared(io.vertx.core.Vertx, JsonObject, String)
but with the default data source namevertx
- the Vert.x instanceconfig
- the configurationMongoClient save(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler)
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 oneMongoClient saveWithOptions(String collection, JsonObject document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)
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 oneMongoClient insert(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler)
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 oneMongoClient insertWithOptions(String collection, JsonObject document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)
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 one@Deprecated MongoClient update(String collection, JsonObject query, JsonObject update, Handler<AsyncResult<Void>> resultHandler)
updateCollection(String, JsonObject, JsonObject, Handler)
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedresultHandler
- will be called when completeMongoClient updateCollection(String collection, JsonObject query, JsonObject update, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedresultHandler
- will be called when complete@Deprecated MongoClient updateWithOptions(String collection, JsonObject query, JsonObject update, UpdateOptions options, Handler<AsyncResult<Void>> resultHandler)
updateCollectionWithOptions(String, JsonObject, JsonObject, UpdateOptions, Handler)
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedoptions
- options to configure the updateresultHandler
- will be called when completeMongoClient updateCollectionWithOptions(String collection, JsonObject query, JsonObject update, UpdateOptions options, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedoptions
- options to configure the updateresultHandler
- will be called when complete@Deprecated MongoClient replace(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<Void>> resultHandler)
replaceDocuments(String, JsonObject, JsonObject, Handler)
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 completeMongoClient replaceDocuments(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
collection
- the collectionquery
- query used to match the documentsreplace
- all matching documents will be replaced with thisresultHandler
- will be called when complete@Deprecated MongoClient replaceWithOptions(String collection, JsonObject query, JsonObject replace, UpdateOptions options, Handler<AsyncResult<Void>> resultHandler)
replaceDocumentsWithOptions(String, JsonObject, JsonObject, UpdateOptions, Handler)
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 replaceresultHandler
- will be called when completeMongoClient replaceDocumentsWithOptions(String collection, JsonObject query, JsonObject replace, UpdateOptions options, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
collection
- the collectionquery
- query used to match the documentsreplace
- all matching documents will be replaced with thisoptions
- options to configure the replaceresultHandler
- will be called when completeMongoClient bulkWrite(String collection, List<BulkOperation> operations, Handler<AsyncResult<MongoClientBulkWriteResult>> resultHandler)
collection
- the collectionoperations
- the operations to executeresultHandler
- will be called with a MongoClientBulkWriteResult
when completeMongoClient bulkWriteWithOptions(String collection, List<BulkOperation> operations, BulkWriteOptions bulkWriteOptions, Handler<AsyncResult<MongoClientBulkWriteResult>> resultHandler)
collection
- the collectionoperations
- the operations to executebulkWriteOptions
- the write optionsresultHandler
- will be called with a MongoClientBulkWriteResult
when completeMongoClient find(String collection, JsonObject query, Handler<AsyncResult<List<JsonObject>>> resultHandler)
collection
- the collectionquery
- query used to match documentsresultHandler
- will be provided with list of documentsReadStream<JsonObject> findBatch(String collection, JsonObject query)
collection
- the collectionquery
- query used to match documentsReadStream
emitting found documentsMongoClient findWithOptions(String collection, JsonObject query, FindOptions options, Handler<AsyncResult<List<JsonObject>>> resultHandler)
collection
- the collectionquery
- query used to match documentsoptions
- options to configure the findresultHandler
- will be provided with list of documentsReadStream<JsonObject> findBatchWithOptions(String collection, JsonObject query, FindOptions options)
collection
- the collectionquery
- query used to match documentsoptions
- options to configure the findReadStream
emitting found documentsMongoClient findOne(String collection, JsonObject query, JsonObject fields, Handler<AsyncResult<JsonObject>> resultHandler)
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 anyMongoClient findOneAndUpdate(String collection, JsonObject query, JsonObject update, Handler<AsyncResult<JsonObject>> resultHandler)
This operation might change _id field of query parameter
collection
- the collectionquery
- the query used to match the documentupdate
- used to describe how the documents will be updatedresultHandler
- will be provided with the document, if anyMongoClient findOneAndUpdateWithOptions(String collection, JsonObject query, JsonObject update, FindOptions findOptions, UpdateOptions updateOptions, Handler<AsyncResult<JsonObject>> resultHandler)
This operation might change _id field of query parameter
collection
- the collectionquery
- the query used to match the documentupdate
- used to describe how the documents will be updatedfindOptions
- options to configure the findupdateOptions
- options to configure the updateresultHandler
- will be provided with the document, if anyMongoClient findOneAndReplace(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<JsonObject>> resultHandler)
This operation might change _id field of query parameter
collection
- the collectionquery
- the query used to match the documentreplace
- the replacement documentresultHandler
- will be provided with the document, if anyMongoClient findOneAndReplaceWithOptions(String collection, JsonObject query, JsonObject replace, FindOptions findOptions, UpdateOptions updateOptions, Handler<AsyncResult<JsonObject>> resultHandler)
This operation might change _id field of query parameter
collection
- the collectionquery
- the query used to match the documentreplace
- the replacement documentfindOptions
- options to configure the findupdateOptions
- options to configure the updateresultHandler
- will be provided with the document, if anyMongoClient findOneAndDelete(String collection, JsonObject query, Handler<AsyncResult<JsonObject>> resultHandler)
This operation might change _id field of query parameter
collection
- the collectionquery
- the query used to match the documentresultHandler
- will be provided with the deleted document, if anyMongoClient findOneAndDeleteWithOptions(String collection, JsonObject query, FindOptions findOptions, Handler<AsyncResult<JsonObject>> resultHandler)
This operation might change _id field of query parameter
collection
- the collectionquery
- the query used to match the documentfindOptions
- options to configure the findresultHandler
- will be provided with the deleted document, if anyMongoClient count(String collection, JsonObject query, Handler<AsyncResult<Long>> resultHandler)
collection
- the collectionquery
- query used to match documentsresultHandler
- will be provided with the number of matching documents@Deprecated MongoClient remove(String collection, JsonObject query, Handler<AsyncResult<Void>> resultHandler)
removeDocuments(String, JsonObject, Handler)
collection
- the collectionquery
- query used to match documentsresultHandler
- will be called when completeMongoClient removeDocuments(String collection, JsonObject query, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
collection
- the collectionquery
- query used to match documentsresultHandler
- will be called when complete@Deprecated MongoClient removeWithOptions(String collection, JsonObject query, WriteOption writeOption, Handler<AsyncResult<Void>> resultHandler)
removeDocumentsWithOptions(String, JsonObject, WriteOption, Handler)
collection
- the collectionquery
- query used to match documentswriteOption
- the write option to useresultHandler
- will be called when completeMongoClient removeDocumentsWithOptions(String collection, JsonObject query, WriteOption writeOption, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
collection
- the collectionquery
- query used to match documentswriteOption
- the write option to useresultHandler
- will be called when complete@Deprecated MongoClient removeOne(String collection, JsonObject query, Handler<AsyncResult<Void>> resultHandler)
removeDocument(String, JsonObject, Handler)
collection
- the collectionquery
- query used to match documentresultHandler
- will be called when completeMongoClient removeDocument(String collection, JsonObject query, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
collection
- the collectionquery
- query used to match documentresultHandler
- will be called when complete@Deprecated MongoClient removeOneWithOptions(String collection, JsonObject query, WriteOption writeOption, Handler<AsyncResult<Void>> resultHandler)
removeDocumentsWithOptions(String, JsonObject, WriteOption, Handler)
collection
- the collectionquery
- query used to match documentwriteOption
- the write option to useresultHandler
- will be called when completeMongoClient removeDocumentWithOptions(String collection, JsonObject query, WriteOption writeOption, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
collection
- the collectionquery
- query used to match documentwriteOption
- the write option to useresultHandler
- will be called when completeMongoClient createCollection(String collectionName, Handler<AsyncResult<Void>> resultHandler)
collectionName
- the name of the collectionresultHandler
- will be called when completeMongoClient getCollections(Handler<AsyncResult<List<String>>> resultHandler)
resultHandler
- will be called with a list of collections.MongoClient dropCollection(String collection, Handler<AsyncResult<Void>> resultHandler)
collection
- the collectionresultHandler
- will be called when completeMongoClient createIndex(String collection, JsonObject key, Handler<AsyncResult<Void>> resultHandler)
collection
- the collectionkey
- A document that contains the field and value pairs where the field is the index key and the value
describes the type of index for that field. For an ascending index on a field,
specify a value of 1; for descending index, specify a value of -1.resultHandler
- will be called when completeMongoClient createIndexWithOptions(String collection, JsonObject key, IndexOptions options, Handler<AsyncResult<Void>> resultHandler)
collection
- the collectionkey
- A document that contains the field and value pairs where the field is the index key and the value
describes the type of index for that field. For an ascending index on a field,
specify a value of 1; for descending index, specify a value of -1.options
- the options for the indexresultHandler
- will be called when completeMongoClient listIndexes(String collection, Handler<AsyncResult<JsonArray>> resultHandler)
collection
- the collectionresultHandler
- will be called when completeMongoClient dropIndex(String collection, String indexName, Handler<AsyncResult<Void>> resultHandler)
collection
- the collectionindexName
- the name of the index to removeresultHandler
- will be called when completeMongoClient runCommand(String commandName, JsonObject command, Handler<AsyncResult<JsonObject>> resultHandler)
commandName
- the name of the commandcommand
- the commandresultHandler
- will be called with the result.MongoClient distinct(String collection, String fieldName, String resultClassname, Handler<AsyncResult<JsonArray>> resultHandler)
collection
- the collectionfieldName
- the field nameresultHandler
- will be provided with array of values.MongoClient distinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, Handler<AsyncResult<JsonArray>> resultHandler)
collection
- the collectionfieldName
- the field namequery
- the queryresultHandler
- will be provided with array of values.ReadStream<JsonObject> distinctBatch(String collection, String fieldName, String resultClassname)
collection
- the collectionfieldName
- the field nameReadStream
emitting json fragmentsReadStream<JsonObject> distinctBatchWithQuery(String collection, String fieldName, String resultClassname, JsonObject query)
collection
- the collectionfieldName
- the field namequery
- the queryReadStream
emitting json fragmentsReadStream<JsonObject> distinctBatchWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, int batchSize)
collection
- the collectionfieldName
- the field namequery
- the querybatchSize
- the number of documents to load in a batchReadStream
emitting json fragmentsReadStream<JsonObject> aggregate(String collection, JsonArray pipeline)
AggregateOptions
.collection
- the collectionpipeline
- aggregation pipeline to be executedReadStream<JsonObject> aggregateWithOptions(String collection, JsonArray pipeline, AggregateOptions options)
collection
- the collectionpipeline
- aggregation pipeline to be executedoptions
- options to configure the aggregation commandvoid close()
Copyright © 2023 Eclipse. All rights reserved.