CFMongoDB

cfmongodb.core
Class MongoUtil

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

public class MongoUtil
extends WEB-INF.cftags.component

Constructor Summary
init([any mongoFactory=''])
          initialize the MongoUtil
 
Method Summary
 any GETMONGOFACTORY()
 void SETMONGOFACTORY(any mongoFactory)
 any createOrderedDBObject([any keyValues], [any dbObject=''])
          Creates a Mongo CFBasicDBObject whose order matches the order of the keyValues argument keyValues can be: 1) a string in k,k format: "STATUS,TS"
 any getDateFromDoc([any doc])
          Extracts the timestamp from the Doc's ObjectId
 any getDocumentTyperClass()
          returns the typer class name to use for Document and Query objects
 any getOperationTyperClass()
          returns a simple typer class that only concerns itself with 1, -1, and 0, which MongoDB uses for operation decision making such as sorting and field selection
 any isCFBasicDBObject([any doc])
          Whether this doc is an instance of a CFMongoDB CFBasicDBObject
 any listToStruct([any list])
 any newDBObject()
          Create a new instance of the CFBasicDBObject
 any newDBObjectBuilder()
          Create a new instance of a CFBasicDBObjectBuilder
 any newIDCriteriaObject([String id])
          Convenience for creating a new criteria object based on a string _id
 any newObjectIDFromID([String id])
          Convenience for turning a string _id into a Mongo ObjectId object
 any newOperationalDBObject()
          Create a new instance of the CFBasicDBObject for use in operational (i
 any toCF([any BasicDBObject])
          Converts a Mongo DBObject to a ColdFusion structure
 any toMongo([any data])
          Converts a ColdFusion structure to a CFBasicDBobject, which the Java drivers can use
 any toMongoOperation([struct data])
          Converts a ColdFusion structure to a CFBasicDBobject which ensures 1 and -1 remain ints
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init([any mongoFactory=''])
initialize the MongoUtil. Pass an instance of JavaLoaderFactory to bypass the default MongoFactory Using a JavaLoaderFactory lets you use the libs provided with cfmongodb without adding them to your path and restarting CF

Parameters:
mongoFactory
Method Detail

GETMONGOFACTORY

public any GETMONGOFACTORY()


SETMONGOFACTORY

public void SETMONGOFACTORY(any mongoFactory)

Parameters:
mongoFactory

createOrderedDBObject

public any createOrderedDBObject([any keyValues], [any dbObject=''])
Creates a Mongo CFBasicDBObject whose order matches the order of the keyValues argument keyValues can be: 1) a string in k,k format: "STATUS,TS". This will set the value for each key to "1". Useful for creating Mongo's 'all true' structs, like the "keys" argument to group() 2) a string in k=v format: STATUS=1,TS=-1 3) an array of strings in k=v format: ["STATUS=1","TS=-1"] 4) an array of structs (often necessary when creating "command" objects for passing to db.command()): createOrderedDBObject( [ {"mapreduce"="tasks"}, {"map"=map}, {"reduce"=reduce} ] )

Parameters:
keyValues
dbObject

getDateFromDoc

public any getDateFromDoc([any doc])
Extracts the timestamp from the Doc's ObjectId. This represents the time the document was added to MongoDB

Parameters:
doc

getDocumentTyperClass

public any getDocumentTyperClass()
returns the typer class name to use for Document and Query objects. For Adobe ColdFusion, we need the CFStrictTyper because Adobe CF will treat numbers and booleans as strings. For Railo, we can use the "NoTyper" because Railo treats numbers as numbers and booleans as booleans


getOperationTyperClass

public any getOperationTyperClass()
returns a simple typer class that only concerns itself with 1, -1, and 0, which MongoDB uses for operation decision making such as sorting and field selection


isCFBasicDBObject

public any isCFBasicDBObject([any doc])
Whether this doc is an instance of a CFMongoDB CFBasicDBObject

Parameters:
doc

listToStruct

public any listToStruct([any list])

Parameters:
list

newDBObject

public any newDBObject()
Create a new instance of the CFBasicDBObject. You use these anywhere the Mongo Java driver takes a DBObject


newDBObjectBuilder

public any newDBObjectBuilder()
Create a new instance of a CFBasicDBObjectBuilder


newIDCriteriaObject

public any newIDCriteriaObject([String id])
Convenience for creating a new criteria object based on a string _id

Parameters:
id

newObjectIDFromID

public any newObjectIDFromID([String id])
Convenience for turning a string _id into a Mongo ObjectId object

Parameters:
id

newOperationalDBObject

public any newOperationalDBObject()
Create a new instance of the CFBasicDBObject for use in operational (i.e. non-document-save) situations


toCF

public any toCF([any BasicDBObject])
Converts a Mongo DBObject to a ColdFusion structure

Parameters:
BasicDBObject

toMongo

public any toMongo([any data])
Converts a ColdFusion structure to a CFBasicDBobject, which the Java drivers can use

Parameters:
data

toMongoOperation

public any toMongoOperation([struct data])
Converts a ColdFusion structure to a CFBasicDBobject which ensures 1 and -1 remain ints

Parameters:
data

CFMongoDB