cbmongodb.Mongo

Class Client

lucee.Component
    extended by cbmongodb.Mongo.Client

Mongo Client Maintains the Database Connection via the Native Driver

Class Attributes:
  • singleton : true
  •  
  • license : Apache v2.0
  •  
  • package : cbmongodb.models.Mongo
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Jon Clausen
  •  
    Property Summary
    type property default serializable required
    any collections


    • access = public
    • returntype = any
    true false
    any databases


    • access = public
    • returntype = any
    true false
    any jLoader
          CBJavaloader.

    • access = public
    • returntype = any
    • inject = id:loader@cbjavaloader
    true false
    any Mongo
          Properties created on init().

    • access = public
    • returntype = any
    true false
    any MongoAsync


    • access = public
    • returntype = any
    true false
    any MongoConfig


    • access = public
    • returntype = any
    • inject = id:MongoConfig@cbmongodb
    true false
    any MongoUtil
          Utility Class.

    • access = public
    • returntype = any
    • inject = id:MongoUtil@cbmongodb
    true false
    any ReadPreference


    • access = public
    • returntype = any
    true false
    any wirebox
          Wirebox.

    • access = public
    • returntype = any
    • inject = wirebox
    true false
    any WriteConcern


    • access = public
    • returntype = any
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    any addUser([string username], [string password])
         Adds a user to the database.
    any close()
         Closes the underlying mongodb object.
    any connect(any dbName='[runtime expression]')
         Our connection to the Mongo Server.
    private any createCredential(string username, string password, any authDB='admin')
    any dropDatabase()
         Drops the database currently specified in MongoConfig.
    string getCollections()
    string getDatabases()
    any getDBCollection([any collectionName], [any dbName='[runtime expression]'])
         Gets a CBMongoDB DBCollection object, which wraps the java DBCollection.
    string getJLoader()
    any getLastError()
         Returns the last error for the current connection.
    any getMongo()
         Get the underlying Java driver's Mongo object.
    string getMongoAsync()
    any getMongoConfig([any mongoConfig=''])
         Decide whether to use the MongoConfig in the variables scope, the one being passed around as arguments, or create a new one.
    any getMongoDB([any mongoConfig=''])
         Get the underlying Java driver's DB object.
    string getMongoUtil()
    string getReadPreference()
    string getWirebox()
    string getWriteConcern()
    private any initCollections()
    private any initDatabases()
    any onDIComplete()
         After init the autowire properties.
    any setCollections(any collections)
    any setDatabases(any databases)
    any setJLoader(any jLoader)
    any setMongo(any Mongo)
    any setMongoAsync(any MongoAsync)
    any setMongoConfig(any MongoConfig)
    any setMongoUtil(any MongoUtil)
    any setReadPreference(any ReadPreference)
    any setWirebox(any wirebox)
    any setWriteConcern(any WriteConcern)
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    collections

    property any collections

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    databases

    property any databases

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    jLoader

    property any jLoader

    CBJavaloader

    Attributes:
    access - public
    required - false
    returntype - any
    inject - id:loader@cbjavaloader
    serializable - true

    Mongo

    property any Mongo

    Properties created on init()

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    MongoAsync

    property any MongoAsync

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    MongoConfig

    property any MongoConfig

    Attributes:
    access - public
    required - false
    returntype - any
    inject - id:MongoConfig@cbmongodb
    serializable - true

    MongoUtil

    property any MongoUtil

    Utility Class

    Attributes:
    access - public
    required - false
    returntype - any
    inject - id:MongoUtil@cbmongodb
    serializable - true

    ReadPreference

    property any ReadPreference

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    wirebox

    property any wirebox

    Wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    WriteConcern

    property any WriteConcern

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    addUser

    public any addUser([string username], [string password])

    Adds a user to the database

    Parameters:
    username
    password

    close

    public any close()

    Closes the underlying mongodb object. Once closed, you cannot perform additional mongo operations and you'll need to init a new mongo. Best practice is to close mongo in your Application.cfc's onApplicationStop() method. Something like: getBeanFactory().getBean("mongo").close(); or application.mongo.close() depending on how you're initializing and making mongo available to your app NOTE: If you do not close your mongo object, you WILL leak connections!


    connect

    public any connect(any dbName='[runtime expression]')

    Our connection to the Mongo Server

    Parameters:
    dbName

    createCredential

    private any createCredential(string username, string password, any authDB='admin')

    Parameters:
    username
    password
    authDB

    dropDatabase

    public any dropDatabase()

    Drops the database currently specified in MongoConfig


    getCollections

    public string getCollections()


    getDatabases

    public string getDatabases()


    getDBCollection

    public any getDBCollection([any collectionName], [any dbName='[runtime expression]'])

    Gets a CBMongoDB DBCollection object, which wraps the java DBCollection

    Parameters:
    collectionName
    dbName

    getJLoader

    public string getJLoader()


    getLastError

    public any getLastError()

    Returns the last error for the current connection.


    getMongo

    public any getMongo()

    Get the underlying Java driver's Mongo object


    getMongoAsync

    public string getMongoAsync()


    getMongoConfig

    public any getMongoConfig([any mongoConfig=''])

    Decide whether to use the MongoConfig in the variables scope, the one being passed around as arguments, or create a new one

    Parameters:
    mongoConfig

    getMongoDB

    public any getMongoDB([any mongoConfig=''])

    Get the underlying Java driver's DB object

    Parameters:
    mongoConfig

    getMongoUtil

    public string getMongoUtil()


    getReadPreference

    public string getReadPreference()


    getWirebox

    public string getWirebox()


    getWriteConcern

    public string getWriteConcern()


    initCollections

    private any initCollections()


    initDatabases

    private any initDatabases()


    onDIComplete

    public any onDIComplete()

    After init the autowire properties


    setCollections

    public any setCollections(any collections)

    Parameters:
    collections

    setDatabases

    public any setDatabases(any databases)

    Parameters:
    databases

    setJLoader

    public any setJLoader(any jLoader)

    Parameters:
    jLoader

    setMongo

    public any setMongo(any Mongo)

    Parameters:
    Mongo

    setMongoAsync

    public any setMongoAsync(any MongoAsync)

    Parameters:
    MongoAsync

    setMongoConfig

    public any setMongoConfig(any MongoConfig)

    Parameters:
    MongoConfig

    setMongoUtil

    public any setMongoUtil(any MongoUtil)

    Parameters:
    MongoUtil

    setReadPreference

    public any setReadPreference(any ReadPreference)

    Parameters:
    ReadPreference

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    setWriteConcern

    public any setWriteConcern(any WriteConcern)

    Parameters:
    WriteConcern