io.vertx.ext.mongo

## Interface MongoClient

-     public interface MongoClient

  A Vert.x service used to interact with MongoDB server instances.
  Author:
    Tim Fox

- - ### Field Summary

    Fields
    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

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `MongoClient` | `createCollection(String collectionName, Handler<AsyncResult<Void>> resultHandler)` Create a new collection
    `static MongoClient` | `createNonShared(Vertx vertx, JsonObject config)` Create a Mongo client which maintains its own data source.
    `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` | `dropCollection(String collection, Handler<AsyncResult<Void>> resultHandler)` Drop a collection
    `MongoClient` | `find(String collection, JsonObject query, Handler<AsyncResult<List<JsonObject>>> resultHandler)` Find matching documents in the specified collection
    `MongoClient` | `findOne(String collection, JsonObject query, JsonObject fields, Handler<AsyncResult<JsonObject>> resultHandler)` Find a single matching document in the specified collection
    `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` | `remove(String collection, JsonObject query, Handler<AsyncResult<Void>> resultHandler)` Remove matching documents from a collection
    `MongoClient` | `removeOne(String collection, JsonObject query, Handler<AsyncResult<Void>> resultHandler)` Remove a single matching document from a collection
    `MongoClient` | `removeOneWithOptions(String collection, JsonObject query, WriteOption writeOption, Handler<AsyncResult<Void>> resultHandler)` Remove a single matching document from a collection with the specified write option
    `MongoClient` | `removeWithOptions(String collection, JsonObject query, WriteOption writeOption, Handler<AsyncResult<Void>> resultHandler)` Remove matching documents from a collection with the specified write option
    `MongoClient` | `replace(String collection, JsonObject query, JsonObject replace, Handler<AsyncResult<Void>> resultHandler)` Replace matching documents in the specified collection
    `MongoClient` | `replaceWithOptions(String collection, JsonObject query, JsonObject replace, UpdateOptions options, Handler<AsyncResult<Void>> resultHandler)` Replace matching documents in the specified collection, specifying options
    `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)` Update matching documents in the specified collection
    `MongoClient` | `updateWithOptions(String collection, JsonObject query, JsonObject update, UpdateOptions options, Handler<AsyncResult<Void>> resultHandler)` Update matching documents in the specified collection, specifying options

- - ### Field Detail

    - #### DEFAULT_POOL_NAME

          static final String DEFAULT_POOL_NAME

      The name of the default pool
      See Also:
        Constant Field Values

    - #### DEFAULT_DB_NAME

          static final String DEFAULT_DB_NAME

      The name of the default database
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### createNonShared

          static MongoClient createNonShared(Vertx vertx,
                                             JsonObject config)

      Create a Mongo client which maintains its own data source.
      Parameters:
        `vertx` - the Vert.x instance
        `config` - the configuration
      Returns:
        the client

    - #### createShared

          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 instance
        `config` - the configuration
        `dataSourceName` - the data source name
      Returns:
        the client

    - #### createShared

          static MongoClient createShared(Vertx vertx,
                                          JsonObject config)

      Like `createShared(io.vertx.core.Vertx, JsonObject, String)` but with the default data source name
      Parameters:
        `vertx` - the Vert.x instance
        `config` - the configuration
      Returns:
        the client

    - #### save

          MongoClient save(String collection,
                           JsonObject document,
                           Handler<AsyncResult<String>> resultHandler)

      Save a document in the specified collection
      Parameters:
        `collection` - the collection
        `document` - the document
        `resultHandler` - result handler will be provided with the id if document didn't already have one

    - #### saveWithOptions

          MongoClient saveWithOptions(String collection,
                                      JsonObject document,
                                      WriteOption writeOption,
                                      Handler<AsyncResult<String>> resultHandler)

      Save a document in the specified collection with the specified write option
      Parameters:
        `collection` - the collection
        `document` - the document
        `writeOption` - the write option to use
        `resultHandler` - result handler will be provided with the id if document didn't already have one

    - #### insert

          MongoClient insert(String collection,
                             JsonObject document,
                             Handler<AsyncResult<String>> resultHandler)

      Insert a document in the specified collection
      Parameters:
        `collection` - the collection
        `document` - the document
        `resultHandler` - result handler will be provided with the id if document didn't already have one

    - #### insertWithOptions

          MongoClient insertWithOptions(String collection,
                                        JsonObject document,
                                        WriteOption writeOption,
                                        Handler<AsyncResult<String>> resultHandler)

      Insert a document in the specified collection with the specified write option
      Parameters:
        `collection` - the collection
        `document` - the document
        `writeOption` - the write option to use
        `resultHandler` - result handler will be provided with the id if document didn't already have one

    - #### update

          MongoClient update(String collection,
                             JsonObject query,
                             JsonObject update,
                             Handler<AsyncResult<Void>> resultHandler)

      Update matching documents in the specified collection
      Parameters:
        `collection` - the collection
        `query` - query used to match the documents
        `update` - used to describe how the documents will be updated
        `resultHandler` - will be called when complete

    - #### updateWithOptions

          MongoClient updateWithOptions(String collection,
                                        JsonObject query,
                                        JsonObject update,
                                        UpdateOptions options,
                                        Handler<AsyncResult<Void>> resultHandler)

      Update matching documents in the specified collection, specifying options
      Parameters:
        `collection` - the collection
        `query` - query used to match the documents
        `update` - used to describe how the documents will be updated
        `options` - options to configure the update
        `resultHandler` - will be called when complete

    - #### replace

          MongoClient replace(String collection,
                              JsonObject query,
                              JsonObject replace,
                              Handler<AsyncResult<Void>> resultHandler)

      Replace matching documents in the specified collection
      Parameters:
        `collection` - the collection
        `query` - query used to match the documents
        `replace` - all matching documents will be replaced with this
        `resultHandler` - will be called when complete

    - #### replaceWithOptions

          MongoClient replaceWithOptions(String collection,
                                         JsonObject query,
                                         JsonObject replace,
                                         UpdateOptions options,
                                         Handler<AsyncResult<Void>> resultHandler)

      Replace matching documents in the specified collection, specifying options
      Parameters:
        `collection` - the collection
        `query` - query used to match the documents
        `replace` - all matching documents will be replaced with this
        `options` - options to configure the replace
        `resultHandler` - will be called when complete

    - #### find

          MongoClient find(String collection,
                           JsonObject query,
                           Handler<AsyncResult<List<JsonObject>>> resultHandler)

      Find matching documents in the specified collection
      Parameters:
        `collection` - the collection
        `query` - query used to match documents
        `resultHandler` - will be provided with list of documents

    - #### findWithOptions

          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 collection
        `query` - query used to match documents
        `options` - options to configure the find
        `resultHandler` - will be provided with list of documents

    - #### findOne

          MongoClient findOne(String collection,
                              JsonObject query,
                              JsonObject fields,
                              Handler<AsyncResult<JsonObject>> resultHandler)

      Find a single matching document in the specified collection
      Parameters:
        `collection` - the collection
        `query` - the query used to match the document
        `fields` - the fields
        `resultHandler` - will be provided with the document, if any

    - #### count

          MongoClient count(String collection,
                            JsonObject query,
                            Handler<AsyncResult<Long>> resultHandler)

      Count matching documents in a collection.
      Parameters:
        `collection` - the collection
        `query` - query used to match documents
        `resultHandler` - will be provided with the number of matching documents

    - #### remove

          MongoClient remove(String collection,
                             JsonObject query,
                             Handler<AsyncResult<Void>> resultHandler)

      Remove matching documents from a collection
      Parameters:
        `collection` - the collection
        `query` - query used to match documents
        `resultHandler` - will be called when complete

    - #### removeWithOptions

          MongoClient removeWithOptions(String collection,
                                        JsonObject query,
                                        WriteOption writeOption,
                                        Handler<AsyncResult<Void>> resultHandler)

      Remove matching documents from a collection with the specified write option
      Parameters:
        `collection` - the collection
        `query` - query used to match documents
        `writeOption` - the write option to use
        `resultHandler` - will be called when complete

    - #### removeOne

          MongoClient removeOne(String collection,
                                JsonObject query,
                                Handler<AsyncResult<Void>> resultHandler)

      Remove a single matching document from a collection
      Parameters:
        `collection` - the collection
        `query` - query used to match document
        `resultHandler` - will be called when complete

    - #### removeOneWithOptions

          MongoClient removeOneWithOptions(String collection,
                                           JsonObject query,
                                           WriteOption writeOption,
                                           Handler<AsyncResult<Void>> resultHandler)

      Remove a single matching document from a collection with the specified write option
      Parameters:
        `collection` - the collection
        `query` - query used to match document
        `writeOption` - the write option to use
        `resultHandler` - will be called when complete

    - #### createCollection

          MongoClient createCollection(String collectionName,
                                       Handler<AsyncResult<Void>> resultHandler)

      Create a new collection
      Parameters:
        `collectionName` - the name of the collection
        `resultHandler` - will be called when complete

    - #### getCollections

          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.

    - #### dropCollection

          MongoClient dropCollection(String collection,
                                     Handler<AsyncResult<Void>> resultHandler)

      Drop a collection
      Parameters:
        `collection` - the collection
        `resultHandler` - will be called when complete

    - #### runCommand

          MongoClient runCommand(String commandName,
                                 JsonObject command,
                                 Handler<AsyncResult<JsonObject>> resultHandler)

      Run an arbitrary MongoDB command.
      Parameters:
        `commandName` - the name of the command
        `command` - the command
        `resultHandler` - will be called with the result.

    - #### close

          void close()

      Close the client and release its resources

Copyright © 2015. All Rights Reserved.