CFMongoDB

cfmongodb.core
Class Mongo

WEB-INF.cftags.component
        extended by cfmongodb.core.Mongo

public class Mongo
extends WEB-INF.cftags.component

Constructor Summary
init([any MongoConfig='[runtime expression]'])
          You can init CFMongoDB in two ways: 1) drop the included jars into your CF's lib path (restart CF) 2) use Mark Mandel's javaloader (included)
 
Method Summary
 any GETMONGOFACTORY()
 any GETMONGOUTIL()
 void SETMONGOCONFIG(any mongoConfig)
 void SETMONGOFACTORY(any mongoFactory)
 void SETMONGOUTIL(any mongoUtil)
 any addUser([string username], [string password])
          Adds a user to the database
 void authenticate([string username], [string password])
          Authenticates connection/db with given name and password Typical usage: mongoConfig
 any close()
          Closes the underlying mongodb object
 any distinct([string key], [string collectionName])
          Deprecated
 any dropDatabase()
          Drops the database currently specified in MongoConfig
 array dropIndexes([any collectionName], [any mongoConfig=''])
          Deprecated
 array ensureGeoIndex([any field], [any collectionName], [any min=''], [any max=''])
          Deprecated
 array ensureIndex([array fields], [any collectionName], [any unique='false'])
          Deprecated
 any findAndModify([struct query], [struct fields], [any sort], [boolean remove='false'], [struct update], [boolean returnNew='true'], [boolean upsert='false'], [boolean overwriteExisting='false'], [string collectionName])
          Deprecated
 any findById([any id], [string collectionName])
          Deprecated
 any getDBCollection([any collectionName])
          Gets a CFMongoDB DBCollection object, which wraps the java DBCollection
 array getIndexes([any collectionName])
          Deprecated
 any getLastError()
          Returns the last error for the current connection
 any getMongo()
          Get the underlying Java driver's Mongo object
 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
 any getMongoDBCollection([any collectionName=''])
          Deprecated
 any group([any collectionName], [any keys], [any initial], [any reduce], [any query], [any keyf=''], [any finalize=''])
          Deprecated
private any initCollections()
 any mapReduce([any collectionName], [any map], [any reduce], [any outputTarget], [any outputType='REPLACE'], [any query], [any options])
          Deprecated
 any query([string collectionName], [any mongoConfig=''])
          Deprecated
 any remove([any doc], [any collectionName])
          Deprecated
 any removeById([any id], [any collectionName])
          Deprecated
 any save([struct doc], [string collectionName])
          Deprecated
 any saveAll([array docs], [string collectionName])
          Deprecated
 any update([any doc], [any collectionName], [any query], [any upsert='false'], [any multi='false'], [any overwriteExisting='false'])
          Deprecated
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init([any MongoConfig='[runtime expression]'])
You can init CFMongoDB in two ways: 1) drop the included jars into your CF's lib path (restart CF) 2) use Mark Mandel's javaloader (included). You needn't restart CF) --1: putting the jars into CF's lib path mongoConfig = createObject('component','cfmongodb.core.MongoConfig').init(dbName="mongorocks"); mongo = createObject('component','cfmongodb.core.Mongo').init(mongoConfig); --2: using javaloader javaloaderFactory = createObject('component','cfmongodb.core.JavaloaderFactory').init(); mongoConfig = createObject('component','cfmongodb.core.MongoConfig').init(dbName="mongorocks", mongoFactory=javaloaderFactory); mongo = createObject('component','cfmongodb.core.Mongo').init(mongoConfig); Note that authentication credentials, if set in MongoConfig, will be used to authenticate against the database.

Parameters:
MongoConfig
Method Detail

GETMONGOFACTORY

public any GETMONGOFACTORY()


GETMONGOUTIL

public any GETMONGOUTIL()


SETMONGOCONFIG

public void SETMONGOCONFIG(any mongoConfig)

Parameters:
mongoConfig

SETMONGOFACTORY

public void SETMONGOFACTORY(any mongoFactory)

Parameters:
mongoFactory

SETMONGOUTIL

public void SETMONGOUTIL(any mongoUtil)

Parameters:
mongoUtil

addUser

public any addUser([string username], [string password])
Adds a user to the database

Parameters:
username
password

authenticate

public void authenticate([string username], [string password])
Authenticates connection/db with given name and password Typical usage: mongoConfig.init(...); mongo = new Mongo( mongoConfig ); mongo.authenticate( username, password ); If authentication fails, an error will be thrown

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!


distinct

public any distinct([string key], [string collectionName])
Deprecated. See DBCollection.distinct()

Parameters:
key
collectionName

dropDatabase

public any dropDatabase()
Drops the database currently specified in MongoConfig


dropIndexes

public array dropIndexes([any collectionName], [any mongoConfig=''])
Deprecated. See DBCollection.dropIndexes()

Parameters:
collectionName
mongoConfig

ensureGeoIndex

public array ensureGeoIndex([any field], [any collectionName], [any min=''], [any max=''])
Deprecated. See DBCollection.ensureGeoIndex()

Parameters:
field
collectionName
min
max

ensureIndex

public array ensureIndex([array fields], [any collectionName], [any unique='false'])
Deprecated. See DBCollection.ensureIndex()

Parameters:
fields
collectionName
unique

findAndModify

public any findAndModify([struct query], [struct fields], [any sort], [boolean remove='false'], [struct update], [boolean returnNew='true'], [boolean upsert='false'], [boolean overwriteExisting='false'], [string collectionName])
Deprecated. See DBCollection.findAndModify

Parameters:
query
fields
sort
remove
update
returnNew
upsert
overwriteExisting
collectionName

findById

public any findById([any id], [string collectionName])
Deprecated. See DBCollection.findById()

Parameters:
id
collectionName

getDBCollection

public any getDBCollection([any collectionName])
Gets a CFMongoDB DBCollection object, which wraps the java DBCollection

Parameters:
collectionName

getIndexes

public array getIndexes([any collectionName])
Deprecated. See DBCollection.getIndexes()

Parameters:
collectionName

getLastError

public any getLastError()
Returns the last error for the current connection.


getMongo

public any getMongo()
Get the underlying Java driver's Mongo object


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

getMongoDBCollection

public any getMongoDBCollection([any collectionName=''])
Deprecated. See DBCollection.getMongoDBCollection()

Parameters:
collectionName

group

public any group([any collectionName], [any keys], [any initial], [any reduce], [any query], [any keyf=''], [any finalize=''])
Deprecated. See DBCollection.group()

Parameters:
collectionName
keys
initial
reduce
query
keyf
finalize

initCollections

private any initCollections()


mapReduce

public any mapReduce([any collectionName], [any map], [any reduce], [any outputTarget], [any outputType='REPLACE'], [any query], [any options])
Deprecated. See DBCollection.mapReduce()

Parameters:
collectionName
map
reduce
outputTarget
outputType
query
options

query

public any query([string collectionName], [any mongoConfig=''])
Deprecated. See DBCollection.query()

Parameters:
collectionName
mongoConfig

remove

public any remove([any doc], [any collectionName])
Deprecated. See DBCollection.remove()

Parameters:
doc
collectionName

removeById

public any removeById([any id], [any collectionName])
Deprecated. See DBCollection.removeById()

Parameters:
id
collectionName

save

public any save([struct doc], [string collectionName])
Deprecated. See DBCollection.save()

Parameters:
doc
collectionName

saveAll

public any saveAll([array docs], [string collectionName])
Deprecated. See DBCollection.saveAll()

Parameters:
docs
collectionName

update

public any update([any doc], [any collectionName], [any query], [any upsert='false'], [any multi='false'], [any overwriteExisting='false'])
Deprecated. See DBCollection.update()

Parameters:
doc
collectionName
query
upsert
multi
overwriteExisting

CFMongoDB