public class MongoClientDataSource extends java.lang.Object implements MongoDataSource
Constructor and Description |
---|
MongoClientDataSource(io.vertx.ext.mongo.MongoClient client) |
Modifier and Type | Method and Description |
---|---|
MongoDataSource |
bulkInsert(java.lang.String collection,
java.util.List<io.vertx.core.json.JsonObject> documents,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)
Insert many documents into the collection.
|
MongoDataSource |
count(java.lang.String collection,
io.vertx.core.json.JsonObject query,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)
Count matching documents in a collection.
|
MongoDataSource |
createIndex(java.lang.String collection,
Index index,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)
Creates an index on the collection.
|
MongoDataSource |
deleteIndex(java.lang.String collection,
java.lang.String name,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)
Deletes an index.
|
MongoDataSource |
dropCollection(java.lang.String collection,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)
Drops the collection.
|
MongoDataSource |
find(java.lang.String collection,
io.vertx.core.json.JsonObject query,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<io.vertx.core.json.JsonObject>>> resultHandler)
Find matching documents in the specified collection
|
MongoDataSource |
listIndexes(java.lang.String collection,
io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.json.JsonArray>> resultHandler)
List all indexes.
|
MongoDataSource |
removeDocuments(java.lang.String collection,
io.vertx.core.json.JsonObject query,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)
Remove matching documents in a collection.
|
MongoDataSource |
upsert(java.lang.String collection,
io.vertx.core.json.JsonObject document,
io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler)
Insert or update a document into the collection.
|
public MongoClientDataSource(io.vertx.ext.mongo.MongoClient client)
public MongoDataSource count(java.lang.String collection, io.vertx.core.json.JsonObject query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)
MongoDataSource
count
in interface MongoDataSource
collection
- the collectionquery
- query used to match documentsresultHandler
- will be provided with the number of matching documentspublic MongoDataSource find(java.lang.String collection, io.vertx.core.json.JsonObject query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<io.vertx.core.json.JsonObject>>> resultHandler)
MongoDataSource
find
in interface MongoDataSource
collection
- the collectionquery
- query used to match documentsresultHandler
- will be provided with list of documentspublic MongoDataSource upsert(java.lang.String collection, io.vertx.core.json.JsonObject document, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler)
MongoDataSource
upsert
in interface MongoDataSource
collection
- the collectiondocument
- The document to insert or update.resultHandler
- A handler to handle the AsnycResult which contains a String with the new id (insert), or
null (update).public MongoDataSource bulkInsert(java.lang.String collection, java.util.List<io.vertx.core.json.JsonObject> documents, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)
MongoDataSource
bulkInsert
in interface MongoDataSource
collection
- the collectiondocuments
- A collection of resources to insert into the collection.resultHandler
- A handler to handle the AsnycResult which contains the number of inserted documents.public MongoDataSource removeDocuments(java.lang.String collection, io.vertx.core.json.JsonObject query, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Long>> resultHandler)
MongoDataSource
removeDocuments
in interface MongoDataSource
collection
- the collectionquery
- A filter for the remove request.resultHandler
- A handler to handle the AsnycResult which contains the number of deleted entries.public MongoDataSource dropCollection(java.lang.String collection, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)
MongoDataSource
dropCollection
in interface MongoDataSource
collection
- The collection.resultHandler
- will be called when completepublic MongoDataSource createIndex(java.lang.String collection, Index index, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)
MongoDataSource
createIndex
in interface MongoDataSource
collection
- The collection.resultHandler
- A handler which will be called when the index is created.public MongoDataSource listIndexes(java.lang.String collection, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.json.JsonArray>> resultHandler)
MongoDataSource
listIndexes
in interface MongoDataSource
collection
- The collection.resultHandler
- A handler which contains a JsonArray including indexes.public MongoDataSource deleteIndex(java.lang.String collection, java.lang.String name, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)
MongoDataSource
deleteIndex
in interface MongoDataSource
collection
- The collection.name
- The name of the index which should be deleted.resultHandler
- A handler which will be called when the index is deleted.