Class MongoClient
- java.lang.Object
-
- io.vertx.reactivex.ext.mongo.MongoClient
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<MongoClient>
__TYPE_ARG
static String
DEFAULT_DB_NAME
The name of the default databasestatic String
DEFAULT_POOL_NAME
The name of the default pool
-
Constructor Summary
Constructors Constructor Description MongoClient(MongoClient delegate)
MongoClient(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadStream<JsonObject>
aggregate(String collection, JsonArray pipeline)
Run aggregate MongoDB command with defaultAggregateOptions
.ReadStream<JsonObject>
aggregateWithOptions(String collection, JsonArray pipeline, AggregateOptions options)
Run aggregate MongoDB command.MongoClient
bulkWrite(String collection, List<BulkOperation> operations)
Execute a bulk operation.MongoClient
bulkWrite(String collection, List<BulkOperation> operations, Handler<AsyncResult<MongoClientBulkWriteResult>> resultHandler)
Execute a bulk operation.MongoClient
bulkWriteWithOptions(String collection, List<BulkOperation> operations, BulkWriteOptions bulkWriteOptions)
Execute a bulk operation with the specified write options.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 resourcesvoid
close(Handler<AsyncResult<Void>> handler)
Close the client and release its resourcesMongoClient
count(String collection, JsonObject query)
Count matching documents in a collection.MongoClient
count(String collection, JsonObject query, Handler<AsyncResult<Long>> resultHandler)
Count matching documents in a collection.MongoClient
countWithOptions(String collection, JsonObject query, CountOptions countOptions)
Count matching documents in a collection.MongoClient
countWithOptions(String collection, JsonObject query, CountOptions countOptions, 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)
Create a new collectionMongoClient
createCollection(String collectionName, Handler<AsyncResult<Void>> resultHandler)
Create a new collectionMongoClient
createCollectionWithOptions(String collectionName, CreateCollectionOptions collectionOptions)
Create a new collection with optionsMongoClient
createCollectionWithOptions(String collectionName, CreateCollectionOptions collectionOptions, Handler<AsyncResult<Void>> resultHandler)
Create a new collection with optionsMongoClient
createDefaultGridFsBucketService()
Creates aMongoGridFsClient
used to interact with Mongo GridFS.MongoClient
createDefaultGridFsBucketService(Handler<AsyncResult<MongoGridFsClient>> resultHandler)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.MongoClient
createGridFsBucketService(String bucketName)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.MongoClient
createGridFsBucketService(String bucketName, Handler<AsyncResult<MongoGridFsClient>> resultHandler)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.MongoClient
createIndex(String collection, JsonObject key)
Creates an index.MongoClient
createIndex(String collection, JsonObject key, Handler<AsyncResult<Void>> resultHandler)
Creates an index.MongoClient
createIndexes(String collection, List<IndexModel> indexes)
creates an indexesMongoClient
createIndexes(String collection, List<IndexModel> indexes, Handler<AsyncResult<Void>> resultHandler)
creates an indexesMongoClient
createIndexWithOptions(String collection, JsonObject key, IndexOptions options)
Creates an index.MongoClient
createIndexWithOptions(String collection, JsonObject key, IndexOptions options, Handler<AsyncResult<Void>> resultHandler)
Creates an index.static MongoClient
createShared(Vertx vertx, JsonObject config)
LikecreateShared(io.vertx.reactivex.core.Vertx, io.vertx.core.json.JsonObject, java.lang.String)
but with the default data source namestatic 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 nameMongoClient
distinct(String collection, String fieldName, String resultClassname)
Gets the distinct values of the specified field name.MongoClient
distinct(String collection, String fieldName, String resultClassname, Handler<AsyncResult<JsonArray>> resultHandler)
Gets the distinct values of the specified field name.MongoClient
distinct(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name.MongoClient
distinct(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions, 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>
distinctBatch(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions)
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.ReadStream<JsonObject>
distinctBatchWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, int batchSize, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query.ReadStream<JsonObject>
distinctBatchWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query.MongoClient
distinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query)
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
distinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query.MongoClient
distinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions, Handler<AsyncResult<JsonArray>> resultHandler)
Gets the distinct values of the specified field name filtered by specified query.MongoClient
dropCollection(String collection)
Drop a collectionMongoClient
dropCollection(String collection, Handler<AsyncResult<Void>> resultHandler)
Drop a collectionMongoClient
dropIndex(String collection, String indexName)
Drops the index given its name.MongoClient
dropIndex(String collection, String indexName, Handler<AsyncResult<Void>> resultHandler)
Drops the index given its name.boolean
equals(Object o)
MongoClient
find(String collection, JsonObject query)
Find matching documents in the specified collectionMongoClient
find(String collection, JsonObject query, Handler<AsyncResult<List<JsonObject>>> resultHandler)
Find matching documents in the specified collectionReadStream<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)
Find a single matching document in the specified collectionMongoClient
findOne(String collection, JsonObject query, JsonObject fields, Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collectionMongoClient
findOneAndDelete(String collection, JsonObject query)
Find a single matching document in the specified collection and delete it.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)
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)
Find a single matching document in the specified collection and replace 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)
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)
Find a single matching document in the specified collection and update 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)
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)
Find matching documents in the specified collection, specifying optionsMongoClient
findWithOptions(String collection, JsonObject query, FindOptions options, Handler<AsyncResult<List<JsonObject>>> resultHandler)
Find matching documents in the specified collection, specifying optionsMongoClient
getCollections()
Get a list of all collections in the database.MongoClient
getCollections(Handler<AsyncResult<List<String>>> resultHandler)
Get a list of all collections in the database.MongoClient
getDelegate()
int
hashCode()
MongoClient
insert(String collection, JsonObject document)
Insert a document in the specified collectionMongoClient
insert(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler)
Insert a document in the specified collectionMongoClient
insertWithOptions(String collection, JsonObject document, WriteOption writeOption)
Insert a document in the specified collection with the specified write optionMongoClient
insertWithOptions(String collection, JsonObject document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)
Insert a document in the specified collection with the specified write optionMongoClient
listIndexes(String collection)
Get all the indexes in this collection.MongoClient
listIndexes(String collection, Handler<AsyncResult<JsonArray>> resultHandler)
Get all the indexes in this collection.static MongoClient
newInstance(MongoClient arg)
MongoClient
removeDocument(String collection, JsonObject query)
Remove a single matching document from a collection and return the handler withMongoClientDeleteResult
resultMongoClient
removeDocument(String collection, JsonObject query, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove a single matching document from a collection and return the handler withMongoClientDeleteResult
resultMongoClient
removeDocuments(String collection, JsonObject query)
Remove matching documents from a collection and return the handler withMongoClientDeleteResult
resultMongoClient
removeDocuments(String collection, JsonObject query, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove matching documents from a collection and return the handler withMongoClientDeleteResult
resultMongoClient
removeDocumentsWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove matching documents from a collection with the specified write option and return the handler withMongoClientDeleteResult
resultMongoClient
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 withMongoClientDeleteResult
resultMongoClient
removeDocumentWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove a single matching document from a collection with the specified write option and return the handler withMongoClientDeleteResult
resultMongoClient
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 withMongoClientDeleteResult
resultMongoClient
replaceDocuments(String collection, JsonObject query, JsonObject replace)
Replace matching documents in the specified collection and return the handler withMongoClientUpdateResult
resultMongoClient
replaceDocuments(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Replace matching documents in the specified collection and return the handler withMongoClientUpdateResult
resultMongoClient
replaceDocumentsWithOptions(String collection, JsonObject query, JsonObject replace, UpdateOptions options)
Replace matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
resultMongoClient
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 withMongoClientUpdateResult
resultMongoClient
runCommand(String commandName, JsonObject command)
Run an arbitrary MongoDB command.MongoClient
runCommand(String commandName, JsonObject command, Handler<AsyncResult<JsonObject>> resultHandler)
Run an arbitrary MongoDB command.io.reactivex.Maybe<MongoClientBulkWriteResult>
rxBulkWrite(String collection, List<BulkOperation> operations)
Execute a bulk operation.io.reactivex.Maybe<MongoClientBulkWriteResult>
rxBulkWriteWithOptions(String collection, List<BulkOperation> operations, BulkWriteOptions bulkWriteOptions)
Execute a bulk operation with the specified write options.io.reactivex.Completable
rxClose()
Close the client and release its resourcesio.reactivex.Single<Long>
rxCount(String collection, JsonObject query)
Count matching documents in a collection.io.reactivex.Single<Long>
rxCountWithOptions(String collection, JsonObject query, CountOptions countOptions)
Count matching documents in a collection.io.reactivex.Completable
rxCreateCollection(String collectionName)
Create a new collectionio.reactivex.Completable
rxCreateCollectionWithOptions(String collectionName, CreateCollectionOptions collectionOptions)
Create a new collection with optionsio.reactivex.Single<MongoGridFsClient>
rxCreateDefaultGridFsBucketService()
Creates aMongoGridFsClient
used to interact with Mongo GridFS.io.reactivex.Single<MongoGridFsClient>
rxCreateGridFsBucketService(String bucketName)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.io.reactivex.Completable
rxCreateIndex(String collection, JsonObject key)
Creates an index.io.reactivex.Completable
rxCreateIndexes(String collection, List<IndexModel> indexes)
creates an indexesio.reactivex.Completable
rxCreateIndexWithOptions(String collection, JsonObject key, IndexOptions options)
Creates an index.io.reactivex.Single<JsonArray>
rxDistinct(String collection, String fieldName, String resultClassname)
Gets the distinct values of the specified field name.io.reactivex.Single<JsonArray>
rxDistinct(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name.io.reactivex.Single<JsonArray>
rxDistinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query)
Gets the distinct values of the specified field name filtered by specified query.io.reactivex.Single<JsonArray>
rxDistinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query.io.reactivex.Completable
rxDropCollection(String collection)
Drop a collectionio.reactivex.Completable
rxDropIndex(String collection, String indexName)
Drops the index given its name.io.reactivex.Single<List<JsonObject>>
rxFind(String collection, JsonObject query)
Find matching documents in the specified collectionio.reactivex.Maybe<JsonObject>
rxFindOne(String collection, JsonObject query, JsonObject fields)
Find a single matching document in the specified collectionio.reactivex.Maybe<JsonObject>
rxFindOneAndDelete(String collection, JsonObject query)
Find a single matching document in the specified collection and delete it.io.reactivex.Maybe<JsonObject>
rxFindOneAndDeleteWithOptions(String collection, JsonObject query, FindOptions findOptions)
Find a single matching document in the specified collection and delete it.io.reactivex.Maybe<JsonObject>
rxFindOneAndReplace(String collection, JsonObject query, JsonObject replace)
Find a single matching document in the specified collection and replace it.io.reactivex.Maybe<JsonObject>
rxFindOneAndReplaceWithOptions(String collection, JsonObject query, JsonObject replace, FindOptions findOptions, UpdateOptions updateOptions)
Find a single matching document in the specified collection and replace it.io.reactivex.Maybe<JsonObject>
rxFindOneAndUpdate(String collection, JsonObject query, JsonObject update)
Find a single matching document in the specified collection and update it.io.reactivex.Maybe<JsonObject>
rxFindOneAndUpdateWithOptions(String collection, JsonObject query, JsonObject update, FindOptions findOptions, UpdateOptions updateOptions)
Find a single matching document in the specified collection and update it.io.reactivex.Single<List<JsonObject>>
rxFindWithOptions(String collection, JsonObject query, FindOptions options)
Find matching documents in the specified collection, specifying optionsio.reactivex.Single<List<String>>
rxGetCollections()
Get a list of all collections in the database.io.reactivex.Maybe<String>
rxInsert(String collection, JsonObject document)
Insert a document in the specified collectionio.reactivex.Maybe<String>
rxInsertWithOptions(String collection, JsonObject document, WriteOption writeOption)
Insert a document in the specified collection with the specified write optionio.reactivex.Single<JsonArray>
rxListIndexes(String collection)
Get all the indexes in this collection.io.reactivex.Maybe<MongoClientDeleteResult>
rxRemoveDocument(String collection, JsonObject query)
Remove a single matching document from a collection and return the handler withMongoClientDeleteResult
resultio.reactivex.Maybe<MongoClientDeleteResult>
rxRemoveDocuments(String collection, JsonObject query)
Remove matching documents from a collection and return the handler withMongoClientDeleteResult
resultio.reactivex.Maybe<MongoClientDeleteResult>
rxRemoveDocumentsWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove matching documents from a collection with the specified write option and return the handler withMongoClientDeleteResult
resultio.reactivex.Maybe<MongoClientDeleteResult>
rxRemoveDocumentWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove a single matching document from a collection with the specified write option and return the handler withMongoClientDeleteResult
resultio.reactivex.Maybe<MongoClientUpdateResult>
rxReplaceDocuments(String collection, JsonObject query, JsonObject replace)
Replace matching documents in the specified collection and return the handler withMongoClientUpdateResult
resultio.reactivex.Maybe<MongoClientUpdateResult>
rxReplaceDocumentsWithOptions(String collection, JsonObject query, JsonObject replace, UpdateOptions options)
Replace matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
resultio.reactivex.Maybe<JsonObject>
rxRunCommand(String commandName, JsonObject command)
Run an arbitrary MongoDB command.io.reactivex.Maybe<String>
rxSave(String collection, JsonObject document)
Save a document in the specified collectionio.reactivex.Maybe<String>
rxSaveWithOptions(String collection, JsonObject document, WriteOption writeOption)
Save a document in the specified collection with the specified write optionio.reactivex.Maybe<MongoClientUpdateResult>
rxUpdateCollection(String collection, JsonObject query, JsonArray update)
Use an aggregation pipeline to update documents in the specified collection and return the handler withMongoClientUpdateResult
resultio.reactivex.Maybe<MongoClientUpdateResult>
rxUpdateCollection(String collection, JsonObject query, JsonObject update)
Update matching documents in the specified collection and return the handler withMongoClientUpdateResult
resultio.reactivex.Maybe<MongoClientUpdateResult>
rxUpdateCollectionWithOptions(String collection, JsonObject query, JsonArray update, UpdateOptions options)
Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
resultio.reactivex.Maybe<MongoClientUpdateResult>
rxUpdateCollectionWithOptions(String collection, JsonObject query, JsonObject update, UpdateOptions options)
Update matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
resultMongoClient
save(String collection, JsonObject document)
Save a document in the specified collectionMongoClient
save(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler)
Save a document in the specified collectionMongoClient
saveWithOptions(String collection, JsonObject document, WriteOption writeOption)
Save a document in the specified collection with the specified write optionMongoClient
saveWithOptions(String collection, JsonObject document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)
Save a document in the specified collection with the specified write optionString
toString()
MongoClient
updateCollection(String collection, JsonObject query, JsonArray update)
Use an aggregation pipeline to update documents in the specified collection and return the handler withMongoClientUpdateResult
resultMongoClient
updateCollection(String collection, JsonObject query, JsonArray update, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Use an aggregation pipeline to update documents in the specified collection and return the handler withMongoClientUpdateResult
resultMongoClient
updateCollection(String collection, JsonObject query, JsonObject update)
Update matching documents in the specified collection and return the handler withMongoClientUpdateResult
resultMongoClient
updateCollection(String collection, JsonObject query, JsonObject update, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Update matching documents in the specified collection and return the handler withMongoClientUpdateResult
resultMongoClient
updateCollectionWithOptions(String collection, JsonObject query, JsonArray update, UpdateOptions options)
Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
resultMongoClient
updateCollectionWithOptions(String collection, JsonObject query, JsonArray update, UpdateOptions options, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
resultMongoClient
updateCollectionWithOptions(String collection, JsonObject query, JsonObject update, UpdateOptions options)
Update matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
resultMongoClient
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 withMongoClientUpdateResult
resultReadStream<com.mongodb.client.model.changestream.ChangeStreamDocument<JsonObject>>
watch(String collection, JsonArray pipeline, boolean withUpdatedDoc, int batchSize)
Watch the collection change.
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<MongoClient> __TYPE_ARG
-
DEFAULT_POOL_NAME
public static final String DEFAULT_POOL_NAME
The name of the default pool- See Also:
- Constant Field Values
-
DEFAULT_DB_NAME
public static final String DEFAULT_DB_NAME
The name of the default database- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MongoClient
public MongoClient(MongoClient delegate)
-
MongoClient
public MongoClient(Object delegate)
-
-
Method Detail
-
getDelegate
public MongoClient getDelegate()
-
create
public static MongoClient create(Vertx vertx, JsonObject config)
Create a Mongo client which maintains its own data source.- Parameters:
vertx
- the Vert.x instanceconfig
- the configuration- Returns:
- the client
-
createShared
public 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- Parameters:
vertx
- the Vert.x instanceconfig
- the configurationdataSourceName
- the data source name- Returns:
- the client
-
createShared
public static MongoClient createShared(Vertx vertx, JsonObject config)
LikecreateShared(io.vertx.reactivex.core.Vertx, io.vertx.core.json.JsonObject, java.lang.String)
but with the default data source name- Parameters:
vertx
- the Vert.x instanceconfig
- the configuration- Returns:
- the client
-
save
public MongoClient save(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler)
Save a document in the specified collectionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the documentresultHandler
- result handler will be provided with the id if document didn't already have one- Returns:
-
save
public MongoClient save(String collection, JsonObject document)
Save a document in the specified collectionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the document- Returns:
-
rxSave
public io.reactivex.Maybe<String> rxSave(String collection, JsonObject document)
Save a document in the specified collectionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the document- Returns:
-
saveWithOptions
public MongoClient saveWithOptions(String collection, JsonObject document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)
Save a document in the specified collection with the specified write optionThis operation might change _id field of document parameter
- Parameters:
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- Returns:
-
saveWithOptions
public MongoClient saveWithOptions(String collection, JsonObject document, WriteOption writeOption)
Save a document in the specified collection with the specified write optionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the documentwriteOption
- the write option to use- Returns:
-
rxSaveWithOptions
public io.reactivex.Maybe<String> rxSaveWithOptions(String collection, JsonObject document, WriteOption writeOption)
Save a document in the specified collection with the specified write optionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the documentwriteOption
- the write option to use- Returns:
-
insert
public MongoClient insert(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler)
Insert a document in the specified collectionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the documentresultHandler
- result handler will be provided with the id if document didn't already have one- Returns:
-
insert
public MongoClient insert(String collection, JsonObject document)
Insert a document in the specified collectionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the document- Returns:
-
rxInsert
public io.reactivex.Maybe<String> rxInsert(String collection, JsonObject document)
Insert a document in the specified collectionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the document- Returns:
-
insertWithOptions
public MongoClient insertWithOptions(String collection, JsonObject document, WriteOption writeOption, Handler<AsyncResult<String>> resultHandler)
Insert a document in the specified collection with the specified write optionThis operation might change _id field of document parameter
- Parameters:
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- Returns:
-
insertWithOptions
public MongoClient insertWithOptions(String collection, JsonObject document, WriteOption writeOption)
Insert a document in the specified collection with the specified write optionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the documentwriteOption
- the write option to use- Returns:
-
rxInsertWithOptions
public io.reactivex.Maybe<String> rxInsertWithOptions(String collection, JsonObject document, WriteOption writeOption)
Insert a document in the specified collection with the specified write optionThis operation might change _id field of document parameter
- Parameters:
collection
- the collectiondocument
- the documentwriteOption
- the write option to use- Returns:
-
updateCollection
public MongoClient updateCollection(String collection, JsonObject query, JsonObject update, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Update matching documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedresultHandler
- will be called with aMongoClientUpdateResult
when complete- Returns:
-
updateCollection
public MongoClient updateCollection(String collection, JsonObject query, JsonObject update)
Update matching documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updated- Returns:
-
rxUpdateCollection
public io.reactivex.Maybe<MongoClientUpdateResult> rxUpdateCollection(String collection, JsonObject query, JsonObject update)
Update matching documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updated- Returns:
-
updateCollection
public MongoClient updateCollection(String collection, JsonObject query, JsonArray update, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Use an aggregation pipeline to update documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedresultHandler
- will be called with aMongoClientUpdateResult
when complete- Returns:
-
updateCollection
public MongoClient updateCollection(String collection, JsonObject query, JsonArray update)
Use an aggregation pipeline to update documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updated- Returns:
-
rxUpdateCollection
public io.reactivex.Maybe<MongoClientUpdateResult> rxUpdateCollection(String collection, JsonObject query, JsonArray update)
Use an aggregation pipeline to update documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updated- Returns:
-
updateCollectionWithOptions
public 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 withMongoClientUpdateResult
result- Parameters:
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 with aMongoClientUpdateResult
when complete- Returns:
-
updateCollectionWithOptions
public MongoClient updateCollectionWithOptions(String collection, JsonObject query, JsonObject update, UpdateOptions options)
Update matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedoptions
- options to configure the update- Returns:
-
rxUpdateCollectionWithOptions
public io.reactivex.Maybe<MongoClientUpdateResult> rxUpdateCollectionWithOptions(String collection, JsonObject query, JsonObject update, UpdateOptions options)
Update matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- used to describe how the documents will be updatedoptions
- options to configure the update- Returns:
-
updateCollectionWithOptions
public MongoClient updateCollectionWithOptions(String collection, JsonObject query, JsonArray update, UpdateOptions options, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- aggregation pipeline used to describe how documents will be updatedoptions
- options to configure the updateresultHandler
- will be called with aMongoClientUpdateResult
when complete- Returns:
-
updateCollectionWithOptions
public MongoClient updateCollectionWithOptions(String collection, JsonObject query, JsonArray update, UpdateOptions options)
Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- aggregation pipeline used to describe how documents will be updatedoptions
- options to configure the update- Returns:
-
rxUpdateCollectionWithOptions
public io.reactivex.Maybe<MongoClientUpdateResult> rxUpdateCollectionWithOptions(String collection, JsonObject query, JsonArray update, UpdateOptions options)
Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsupdate
- aggregation pipeline used to describe how documents will be updatedoptions
- options to configure the update- Returns:
-
replaceDocuments
public MongoClient replaceDocuments(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<MongoClientUpdateResult>> resultHandler)
Replace matching documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsreplace
- all matching documents will be replaced with thisresultHandler
- will be called with aMongoClientUpdateResult
when complete- Returns:
-
replaceDocuments
public MongoClient replaceDocuments(String collection, JsonObject query, JsonObject replace)
Replace matching documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsreplace
- all matching documents will be replaced with this- Returns:
-
rxReplaceDocuments
public io.reactivex.Maybe<MongoClientUpdateResult> rxReplaceDocuments(String collection, JsonObject query, JsonObject replace)
Replace matching documents in the specified collection and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsreplace
- all matching documents will be replaced with this- Returns:
-
replaceDocumentsWithOptions
public 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 withMongoClientUpdateResult
result- Parameters:
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 with aMongoClientUpdateResult
when complete- Returns:
-
replaceDocumentsWithOptions
public MongoClient replaceDocumentsWithOptions(String collection, JsonObject query, JsonObject replace, UpdateOptions options)
Replace matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsreplace
- all matching documents will be replaced with thisoptions
- options to configure the replace- Returns:
-
rxReplaceDocumentsWithOptions
public io.reactivex.Maybe<MongoClientUpdateResult> rxReplaceDocumentsWithOptions(String collection, JsonObject query, JsonObject replace, UpdateOptions options)
Replace matching documents in the specified collection, specifying options and return the handler withMongoClientUpdateResult
result- Parameters:
collection
- the collectionquery
- query used to match the documentsreplace
- all matching documents will be replaced with thisoptions
- options to configure the replace- Returns:
-
bulkWrite
public MongoClient bulkWrite(String collection, List<BulkOperation> operations, Handler<AsyncResult<MongoClientBulkWriteResult>> resultHandler)
Execute a bulk operation. Can insert, update, replace, and/or delete multiple documents with one request.- Parameters:
collection
- the collectionoperations
- the operations to executeresultHandler
- will be called with aMongoClientBulkWriteResult
when complete- Returns:
-
bulkWrite
public MongoClient bulkWrite(String collection, List<BulkOperation> operations)
Execute a bulk operation. Can insert, update, replace, and/or delete multiple documents with one request.- Parameters:
collection
- the collectionoperations
- the operations to execute- Returns:
-
rxBulkWrite
public io.reactivex.Maybe<MongoClientBulkWriteResult> rxBulkWrite(String collection, List<BulkOperation> operations)
Execute a bulk operation. Can insert, update, replace, and/or delete multiple documents with one request.- Parameters:
collection
- the collectionoperations
- the operations to execute- Returns:
-
bulkWriteWithOptions
public MongoClient bulkWriteWithOptions(String collection, List<BulkOperation> operations, BulkWriteOptions bulkWriteOptions, Handler<AsyncResult<MongoClientBulkWriteResult>> resultHandler)
Execute a bulk operation with the specified write options. Can insert, update, replace, and/or delete multiple documents with one request.- Parameters:
collection
- the collectionoperations
- the operations to executebulkWriteOptions
- the write optionsresultHandler
- will be called with aMongoClientBulkWriteResult
when complete- Returns:
-
bulkWriteWithOptions
public MongoClient bulkWriteWithOptions(String collection, List<BulkOperation> operations, BulkWriteOptions bulkWriteOptions)
Execute a bulk operation with the specified write options. Can insert, update, replace, and/or delete multiple documents with one request.- Parameters:
collection
- the collectionoperations
- the operations to executebulkWriteOptions
- the write options- Returns:
-
rxBulkWriteWithOptions
public io.reactivex.Maybe<MongoClientBulkWriteResult> rxBulkWriteWithOptions(String collection, List<BulkOperation> operations, BulkWriteOptions bulkWriteOptions)
Execute a bulk operation with the specified write options. Can insert, update, replace, and/or delete multiple documents with one request.- Parameters:
collection
- the collectionoperations
- the operations to executebulkWriteOptions
- the write options- Returns:
-
find
public MongoClient find(String collection, JsonObject query, Handler<AsyncResult<List<JsonObject>>> resultHandler)
Find matching documents in the specified collection- Parameters:
collection
- the collectionquery
- query used to match documentsresultHandler
- will be provided with list of documents- Returns:
-
find
public MongoClient find(String collection, JsonObject query)
Find matching documents in the specified collection- Parameters:
collection
- the collectionquery
- query used to match documents- Returns:
-
rxFind
public io.reactivex.Single<List<JsonObject>> rxFind(String collection, JsonObject query)
Find matching documents in the specified collection- Parameters:
collection
- the collectionquery
- query used to match documents- Returns:
-
findBatch
public ReadStream<JsonObject> findBatch(String collection, JsonObject query)
Find matching documents in the specified collection. This method use batchCursor for returning each found document.- Parameters:
collection
- the collectionquery
- query used to match documents- Returns:
- a emitting found documents
-
findWithOptions
public MongoClient findWithOptions(String collection, JsonObject query, FindOptions options, Handler<AsyncResult<List<JsonObject>>> resultHandler)
Find matching documents in the specified collection, specifying options- Parameters:
collection
- the collectionquery
- query used to match documentsoptions
- options to configure the findresultHandler
- will be provided with list of documents- Returns:
-
findWithOptions
public MongoClient findWithOptions(String collection, JsonObject query, FindOptions options)
Find matching documents in the specified collection, specifying options- Parameters:
collection
- the collectionquery
- query used to match documentsoptions
- options to configure the find- Returns:
-
rxFindWithOptions
public io.reactivex.Single<List<JsonObject>> rxFindWithOptions(String collection, JsonObject query, FindOptions options)
Find matching documents in the specified collection, specifying options- Parameters:
collection
- the collectionquery
- query used to match documentsoptions
- options to configure the find- Returns:
-
findBatchWithOptions
public ReadStream<JsonObject> findBatchWithOptions(String collection, JsonObject query, FindOptions options)
Find matching documents in the specified collection, specifying options. This method use batchCursor for returning each found document.- Parameters:
collection
- the collectionquery
- query used to match documentsoptions
- options to configure the find- Returns:
- a emitting found documents
-
findOne
public MongoClient findOne(String collection, JsonObject query, JsonObject fields, Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collectionThis operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentfields
- the fieldsresultHandler
- will be provided with the document, if any- Returns:
-
findOne
public MongoClient findOne(String collection, JsonObject query, JsonObject fields)
Find a single matching document in the specified collectionThis operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentfields
- the fields- Returns:
-
rxFindOne
public io.reactivex.Maybe<JsonObject> rxFindOne(String collection, JsonObject query, JsonObject fields)
Find a single matching document in the specified collectionThis operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentfields
- the fields- Returns:
-
findOneAndUpdate
public MongoClient findOneAndUpdate(String collection, JsonObject query, JsonObject update, Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and update it.This operation might change _id field of query parameter
- Parameters:
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 any- Returns:
-
findOneAndUpdate
public MongoClient findOneAndUpdate(String collection, JsonObject query, JsonObject update)
Find a single matching document in the specified collection and update it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentupdate
- used to describe how the documents will be updated- Returns:
-
rxFindOneAndUpdate
public io.reactivex.Maybe<JsonObject> rxFindOneAndUpdate(String collection, JsonObject query, JsonObject update)
Find a single matching document in the specified collection and update it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentupdate
- used to describe how the documents will be updated- Returns:
-
findOneAndUpdateWithOptions
public 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.This operation might change _id field of query parameter
- Parameters:
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 any- Returns:
-
findOneAndUpdateWithOptions
public MongoClient findOneAndUpdateWithOptions(String collection, JsonObject query, JsonObject update, FindOptions findOptions, UpdateOptions updateOptions)
Find a single matching document in the specified collection and update it.This operation might change _id field of query parameter
- Parameters:
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 update- Returns:
-
rxFindOneAndUpdateWithOptions
public io.reactivex.Maybe<JsonObject> rxFindOneAndUpdateWithOptions(String collection, JsonObject query, JsonObject update, FindOptions findOptions, UpdateOptions updateOptions)
Find a single matching document in the specified collection and update it.This operation might change _id field of query parameter
- Parameters:
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 update- Returns:
-
findOneAndReplace
public MongoClient findOneAndReplace(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and replace it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentreplace
- the replacement documentresultHandler
- will be provided with the document, if any- Returns:
-
findOneAndReplace
public MongoClient findOneAndReplace(String collection, JsonObject query, JsonObject replace)
Find a single matching document in the specified collection and replace it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentreplace
- the replacement document- Returns:
-
rxFindOneAndReplace
public io.reactivex.Maybe<JsonObject> rxFindOneAndReplace(String collection, JsonObject query, JsonObject replace)
Find a single matching document in the specified collection and replace it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentreplace
- the replacement document- Returns:
-
findOneAndReplaceWithOptions
public 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.This operation might change _id field of query parameter
- Parameters:
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 any- Returns:
-
findOneAndReplaceWithOptions
public MongoClient findOneAndReplaceWithOptions(String collection, JsonObject query, JsonObject replace, FindOptions findOptions, UpdateOptions updateOptions)
Find a single matching document in the specified collection and replace it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentreplace
- the replacement documentfindOptions
- options to configure the findupdateOptions
- options to configure the update- Returns:
-
rxFindOneAndReplaceWithOptions
public io.reactivex.Maybe<JsonObject> rxFindOneAndReplaceWithOptions(String collection, JsonObject query, JsonObject replace, FindOptions findOptions, UpdateOptions updateOptions)
Find a single matching document in the specified collection and replace it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentreplace
- the replacement documentfindOptions
- options to configure the findupdateOptions
- options to configure the update- Returns:
-
findOneAndDelete
public MongoClient findOneAndDelete(String collection, JsonObject query, Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and delete it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentresultHandler
- will be provided with the deleted document, if any- Returns:
-
findOneAndDelete
public MongoClient findOneAndDelete(String collection, JsonObject query)
Find a single matching document in the specified collection and delete it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the document- Returns:
-
rxFindOneAndDelete
public io.reactivex.Maybe<JsonObject> rxFindOneAndDelete(String collection, JsonObject query)
Find a single matching document in the specified collection and delete it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the document- Returns:
-
findOneAndDeleteWithOptions
public MongoClient findOneAndDeleteWithOptions(String collection, JsonObject query, FindOptions findOptions, Handler<AsyncResult<JsonObject>> resultHandler)
Find a single matching document in the specified collection and delete it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentfindOptions
- options to configure the findresultHandler
- will be provided with the deleted document, if any- Returns:
-
findOneAndDeleteWithOptions
public MongoClient findOneAndDeleteWithOptions(String collection, JsonObject query, FindOptions findOptions)
Find a single matching document in the specified collection and delete it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentfindOptions
- options to configure the find- Returns:
-
rxFindOneAndDeleteWithOptions
public io.reactivex.Maybe<JsonObject> rxFindOneAndDeleteWithOptions(String collection, JsonObject query, FindOptions findOptions)
Find a single matching document in the specified collection and delete it.This operation might change _id field of query parameter
- Parameters:
collection
- the collectionquery
- the query used to match the documentfindOptions
- options to configure the find- Returns:
-
count
public MongoClient count(String collection, JsonObject query, Handler<AsyncResult<Long>> resultHandler)
Count matching documents in a collection.- Parameters:
collection
- the collectionquery
- query used to match documentsresultHandler
- will be provided with the number of matching documents- Returns:
-
count
public MongoClient count(String collection, JsonObject query)
Count matching documents in a collection.- Parameters:
collection
- the collectionquery
- query used to match documents- Returns:
-
rxCount
public io.reactivex.Single<Long> rxCount(String collection, JsonObject query)
Count matching documents in a collection.- Parameters:
collection
- the collectionquery
- query used to match documents- Returns:
-
countWithOptions
public MongoClient countWithOptions(String collection, JsonObject query, CountOptions countOptions, Handler<AsyncResult<Long>> resultHandler)
Count matching documents in a collection.- Parameters:
collection
- the collectionquery
- query used to match documentscountOptions
-resultHandler
- will be provided with the number of matching documents- Returns:
-
countWithOptions
public MongoClient countWithOptions(String collection, JsonObject query, CountOptions countOptions)
Count matching documents in a collection.- Parameters:
collection
- the collectionquery
- query used to match documentscountOptions
-- Returns:
-
rxCountWithOptions
public io.reactivex.Single<Long> rxCountWithOptions(String collection, JsonObject query, CountOptions countOptions)
Count matching documents in a collection.- Parameters:
collection
- the collectionquery
- query used to match documentscountOptions
-- Returns:
-
removeDocuments
public MongoClient removeDocuments(String collection, JsonObject query, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove matching documents from a collection and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentsresultHandler
- will be called with aMongoClientDeleteResult
when complete- Returns:
-
removeDocuments
public MongoClient removeDocuments(String collection, JsonObject query)
Remove matching documents from a collection and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documents- Returns:
-
rxRemoveDocuments
public io.reactivex.Maybe<MongoClientDeleteResult> rxRemoveDocuments(String collection, JsonObject query)
Remove matching documents from a collection and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documents- Returns:
-
removeDocumentsWithOptions
public 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 withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentswriteOption
- the write option to useresultHandler
- will be called with aMongoClientDeleteResult
when complete- Returns:
-
removeDocumentsWithOptions
public MongoClient removeDocumentsWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove matching documents from a collection with the specified write option and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentswriteOption
- the write option to use- Returns:
-
rxRemoveDocumentsWithOptions
public io.reactivex.Maybe<MongoClientDeleteResult> rxRemoveDocumentsWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove matching documents from a collection with the specified write option and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentswriteOption
- the write option to use- Returns:
-
removeDocument
public MongoClient removeDocument(String collection, JsonObject query, Handler<AsyncResult<MongoClientDeleteResult>> resultHandler)
Remove a single matching document from a collection and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentresultHandler
- will be called with aMongoClientDeleteResult
when complete- Returns:
-
removeDocument
public MongoClient removeDocument(String collection, JsonObject query)
Remove a single matching document from a collection and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match document- Returns:
-
rxRemoveDocument
public io.reactivex.Maybe<MongoClientDeleteResult> rxRemoveDocument(String collection, JsonObject query)
Remove a single matching document from a collection and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match document- Returns:
-
removeDocumentWithOptions
public 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 withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentwriteOption
- the write option to useresultHandler
- will be called with aMongoClientDeleteResult
when complete- Returns:
-
removeDocumentWithOptions
public MongoClient removeDocumentWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove a single matching document from a collection with the specified write option and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentwriteOption
- the write option to use- Returns:
-
rxRemoveDocumentWithOptions
public io.reactivex.Maybe<MongoClientDeleteResult> rxRemoveDocumentWithOptions(String collection, JsonObject query, WriteOption writeOption)
Remove a single matching document from a collection with the specified write option and return the handler withMongoClientDeleteResult
result- Parameters:
collection
- the collectionquery
- query used to match documentwriteOption
- the write option to use- Returns:
-
createCollection
public MongoClient createCollection(String collectionName, Handler<AsyncResult<Void>> resultHandler)
Create a new collection- Parameters:
collectionName
- the name of the collectionresultHandler
- will be called when complete- Returns:
-
createCollection
public MongoClient createCollection(String collectionName)
Create a new collection- Parameters:
collectionName
- the name of the collection- Returns:
-
rxCreateCollection
public io.reactivex.Completable rxCreateCollection(String collectionName)
Create a new collection- Parameters:
collectionName
- the name of the collection- Returns:
-
createCollectionWithOptions
public MongoClient createCollectionWithOptions(String collectionName, CreateCollectionOptions collectionOptions, Handler<AsyncResult<Void>> resultHandler)
Create a new collection with options- Parameters:
collectionName
- the name of the collectioncollectionOptions
- options of the collectionresultHandler
- will be called when complete- Returns:
-
createCollectionWithOptions
public MongoClient createCollectionWithOptions(String collectionName, CreateCollectionOptions collectionOptions)
Create a new collection with options- Parameters:
collectionName
- the name of the collectioncollectionOptions
- options of the collection- Returns:
-
rxCreateCollectionWithOptions
public io.reactivex.Completable rxCreateCollectionWithOptions(String collectionName, CreateCollectionOptions collectionOptions)
Create a new collection with options- Parameters:
collectionName
- the name of the collectioncollectionOptions
- options of the collection- Returns:
-
getCollections
public MongoClient getCollections(Handler<AsyncResult<List<String>>> resultHandler)
Get a list of all collections in the database.- Parameters:
resultHandler
- will be called with a list of collections.- Returns:
-
getCollections
public MongoClient getCollections()
Get a list of all collections in the database.- Returns:
-
rxGetCollections
public io.reactivex.Single<List<String>> rxGetCollections()
Get a list of all collections in the database.- Returns:
-
dropCollection
public MongoClient dropCollection(String collection, Handler<AsyncResult<Void>> resultHandler)
Drop a collection- Parameters:
collection
- the collectionresultHandler
- will be called when complete- Returns:
-
dropCollection
public MongoClient dropCollection(String collection)
Drop a collection- Parameters:
collection
- the collection- Returns:
-
rxDropCollection
public io.reactivex.Completable rxDropCollection(String collection)
Drop a collection- Parameters:
collection
- the collection- Returns:
-
createIndex
public MongoClient createIndex(String collection, JsonObject key, Handler<AsyncResult<Void>> resultHandler)
Creates an index.- Parameters:
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 complete- Returns:
-
createIndex
public MongoClient createIndex(String collection, JsonObject key)
Creates an index.- Parameters:
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.- Returns:
-
rxCreateIndex
public io.reactivex.Completable rxCreateIndex(String collection, JsonObject key)
Creates an index.- Parameters:
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.- Returns:
-
createIndexWithOptions
public MongoClient createIndexWithOptions(String collection, JsonObject key, IndexOptions options, Handler<AsyncResult<Void>> resultHandler)
Creates an index.- Parameters:
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 complete- Returns:
-
createIndexWithOptions
public MongoClient createIndexWithOptions(String collection, JsonObject key, IndexOptions options)
Creates an index.- Parameters:
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 index- Returns:
-
rxCreateIndexWithOptions
public io.reactivex.Completable rxCreateIndexWithOptions(String collection, JsonObject key, IndexOptions options)
Creates an index.- Parameters:
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 index- Returns:
-
createIndexes
public MongoClient createIndexes(String collection, List<IndexModel> indexes, Handler<AsyncResult<Void>> resultHandler)
creates an indexes- Parameters:
collection
- the collectionindexes
- A model that contains pairs of document and indexOptions, document 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 complete- Returns:
-
createIndexes
public MongoClient createIndexes(String collection, List<IndexModel> indexes)
creates an indexes- Parameters:
collection
- the collectionindexes
- A model that contains pairs of document and indexOptions, document 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.- Returns:
-
rxCreateIndexes
public io.reactivex.Completable rxCreateIndexes(String collection, List<IndexModel> indexes)
creates an indexes- Parameters:
collection
- the collectionindexes
- A model that contains pairs of document and indexOptions, document 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.- Returns:
-
listIndexes
public MongoClient listIndexes(String collection, Handler<AsyncResult<JsonArray>> resultHandler)
Get all the indexes in this collection.- Parameters:
collection
- the collectionresultHandler
- will be called when complete- Returns:
-
listIndexes
public MongoClient listIndexes(String collection)
Get all the indexes in this collection.- Parameters:
collection
- the collection- Returns:
-
rxListIndexes
public io.reactivex.Single<JsonArray> rxListIndexes(String collection)
Get all the indexes in this collection.- Parameters:
collection
- the collection- Returns:
-
dropIndex
public MongoClient dropIndex(String collection, String indexName, Handler<AsyncResult<Void>> resultHandler)
Drops the index given its name.- Parameters:
collection
- the collectionindexName
- the name of the index to removeresultHandler
- will be called when complete- Returns:
-
dropIndex
public MongoClient dropIndex(String collection, String indexName)
Drops the index given its name.- Parameters:
collection
- the collectionindexName
- the name of the index to remove- Returns:
-
rxDropIndex
public io.reactivex.Completable rxDropIndex(String collection, String indexName)
Drops the index given its name.- Parameters:
collection
- the collectionindexName
- the name of the index to remove- Returns:
-
runCommand
public MongoClient runCommand(String commandName, JsonObject command, Handler<AsyncResult<JsonObject>> resultHandler)
Run an arbitrary MongoDB command.- Parameters:
commandName
- the name of the commandcommand
- the commandresultHandler
- will be called with the result.- Returns:
-
runCommand
public MongoClient runCommand(String commandName, JsonObject command)
Run an arbitrary MongoDB command.- Parameters:
commandName
- the name of the commandcommand
- the command- Returns:
-
rxRunCommand
public io.reactivex.Maybe<JsonObject> rxRunCommand(String commandName, JsonObject command)
Run an arbitrary MongoDB command.- Parameters:
commandName
- the name of the commandcommand
- the command- Returns:
-
distinct
public MongoClient distinct(String collection, String fieldName, String resultClassname, Handler<AsyncResult<JsonArray>> resultHandler)
Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-resultHandler
- will be provided with array of values.- Returns:
-
distinct
public MongoClient distinct(String collection, String fieldName, String resultClassname)
Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-- Returns:
-
rxDistinct
public io.reactivex.Single<JsonArray> rxDistinct(String collection, String fieldName, String resultClassname)
Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-- Returns:
-
distinct
public MongoClient distinct(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions, Handler<AsyncResult<JsonArray>> resultHandler)
Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-distinctOptions
- options (e.g. collation)resultHandler
- will be provided with array of values.- Returns:
-
distinct
public MongoClient distinct(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-distinctOptions
- options (e.g. collation)- Returns:
-
rxDistinct
public io.reactivex.Single<JsonArray> rxDistinct(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-distinctOptions
- options (e.g. collation)- Returns:
-
distinctWithQuery
public 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. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the queryresultHandler
- will be provided with array of values.- Returns:
-
distinctWithQuery
public MongoClient distinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query)
Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the query- Returns:
-
rxDistinctWithQuery
public io.reactivex.Single<JsonArray> rxDistinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query)
Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the query- Returns:
-
distinctWithQuery
public MongoClient distinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions, Handler<AsyncResult<JsonArray>> resultHandler)
Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the querydistinctOptions
- options (e.g. collation)resultHandler
- will be provided with array of values.- Returns:
-
distinctWithQuery
public MongoClient distinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the querydistinctOptions
- options (e.g. collation)- Returns:
-
rxDistinctWithQuery
public io.reactivex.Single<JsonArray> rxDistinctWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the querydistinctOptions
- options (e.g. collation)- Returns:
-
distinctBatch
public ReadStream<JsonObject> distinctBatch(String collection, String fieldName, String resultClassname)
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}).- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-- Returns:
- a emitting json fragments
-
distinctBatch
public ReadStream<JsonObject> distinctBatch(String collection, String fieldName, String resultClassname, DistinctOptions distinctOptions)
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}).- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-distinctOptions
- options (e.g. collation)- Returns:
- a emitting json fragments
-
distinctBatchWithQuery
public ReadStream<JsonObject> distinctBatchWithQuery(String collection, String fieldName, String resultClassname, JsonObject query)
Gets the distinct values of the specified field name filtered by specified query. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the query- Returns:
- a emitting json fragments
-
distinctBatchWithQuery
public ReadStream<JsonObject> distinctBatchWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the querydistinctOptions
- options (e.g. collation)- Returns:
- a emitting json fragments
-
distinctBatchWithQuery
public 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. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the querybatchSize
- the number of documents to load in a batch- Returns:
- a emitting json fragments
-
distinctBatchWithQuery
public ReadStream<JsonObject> distinctBatchWithQuery(String collection, String fieldName, String resultClassname, JsonObject query, int batchSize, DistinctOptions distinctOptions)
Gets the distinct values of the specified field name filtered by specified query. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).- Parameters:
collection
- the collectionfieldName
- the field nameresultClassname
-query
- the querybatchSize
- the number of documents to load in a batchdistinctOptions
- options (e.g. collation)- Returns:
- a emitting json fragments
-
aggregate
public ReadStream<JsonObject> aggregate(String collection, JsonArray pipeline)
Run aggregate MongoDB command with defaultAggregateOptions
.- Parameters:
collection
- the collectionpipeline
- aggregation pipeline to be executed- Returns:
-
aggregateWithOptions
public ReadStream<JsonObject> aggregateWithOptions(String collection, JsonArray pipeline, AggregateOptions options)
Run aggregate MongoDB command.- Parameters:
collection
- the collectionpipeline
- aggregation pipeline to be executedoptions
- options to configure the aggregation command- Returns:
-
createDefaultGridFsBucketService
public MongoClient createDefaultGridFsBucketService(Handler<AsyncResult<MongoGridFsClient>> resultHandler)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.- Parameters:
resultHandler
- theMongoGridFsClient
to interact with the bucket named bucketName- Returns:
-
createDefaultGridFsBucketService
public MongoClient createDefaultGridFsBucketService()
Creates aMongoGridFsClient
used to interact with Mongo GridFS.- Returns:
-
rxCreateDefaultGridFsBucketService
public io.reactivex.Single<MongoGridFsClient> rxCreateDefaultGridFsBucketService()
Creates aMongoGridFsClient
used to interact with Mongo GridFS.- Returns:
-
createGridFsBucketService
public MongoClient createGridFsBucketService(String bucketName, Handler<AsyncResult<MongoGridFsClient>> resultHandler)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.- Parameters:
bucketName
- the name of the GridFS bucketresultHandler
- theMongoGridFsClient
to interact with the bucket named bucketName- Returns:
-
createGridFsBucketService
public MongoClient createGridFsBucketService(String bucketName)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.- Parameters:
bucketName
- the name of the GridFS bucket- Returns:
-
rxCreateGridFsBucketService
public io.reactivex.Single<MongoGridFsClient> rxCreateGridFsBucketService(String bucketName)
Creates aMongoGridFsClient
used to interact with Mongo GridFS.- Parameters:
bucketName
- the name of the GridFS bucket- Returns:
-
close
public void close(Handler<AsyncResult<Void>> handler)
Close the client and release its resources- Parameters:
handler
-
-
close
public void close()
Close the client and release its resources
-
rxClose
public io.reactivex.Completable rxClose()
Close the client and release its resources- Returns:
-
watch
public ReadStream<com.mongodb.client.model.changestream.ChangeStreamDocument<JsonObject>> watch(String collection, JsonArray pipeline, boolean withUpdatedDoc, int batchSize)
Watch the collection change.- Parameters:
collection
- the collectionpipeline
- watching pipeline to be executedwithUpdatedDoc
- whether to get updated fullDocument for "update" operationbatchSize
- the number of documents to load in a batch- Returns:
-
newInstance
public static MongoClient newInstance(MongoClient arg)
-
-