cbmongodb.Mongo

## Class Collection

    lucee.Component
        cbmongodb.Mongo.Collection

Mongo Collection The collection interface used for client operations by CBMongodb. Handles the translation of CFML objects for the DBCollection instance.

Class Attributes:
- constructor : init(java:com.mongodb.MongoCollectionImpl)
- 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` | collectionName The name of our collection. access = public returntype = any |  | `true` | `false`
`any` | dbCollection The native java Collection Object. access = public returntype = any |  | `true` | `false`
`any` | jLoader CBJavaloader. access = public returntype = any inject = id:loader@cbjavaloader |  | `true` | `false`
`any` | MongoUtil Mongo Utils. access = public returntype = any inject = id:MongoUtil@cbmongodb |  | `true` | `false`

Constructor Summary
init([any dbCollectionInstance]) Constructor - Must be manually instantiated with the Mongo Collection Object.

Method Summary
`any` | aggregate([struct criteria], struct group, [struct projection], [any sort], [any groupMatch]) Performs an aggregation operation on the collection using match or projection.
`any` | aggregation(array command)
`any` | bulkWrite() Facade for the driver's bulkWrite() method.
`any` | count([any criteria='[runtime expression]']) Counts the number of records, by restriction or in total.
`any` | createGeoIndex(string field, any options='[runtime expression]', string geoType='2dsphere') Creates a geospatial index.
`any` | createIndex(any operation, any options='[runtime expression]') Creates a standard index.
`any` | createIndexes(array indexes) Creates multiple indexes.
`any` | deleteMany(any criteria='[runtime expression]') Deletes many documents by criteria.
`any` | deleteOne(any criteria) Deletes a single document by criteria.
`any` | distinct(string fieldName, [struct criteria='[runtime expression]']) Returns the list of distinct values for a specified field name.
`any` | drop() Drops the collection.
`any` | dropIndex([string indexName], [any criteria]) Drops an index Either a name or a criteria to search the existing indexes may be specified.
`any` | dropIndexes() Drops all indexes in a collection.
`any` | find(any criteria='[runtime expression]', struct options='[runtime expression]') Facade for the drivers find method.
`any` | findById(any id) Finds a single document by its _id.
`any` | findOneAndDelete(struct criteria, [any options]) Finds one document and deletes it.
`any` | findOneAndReplace(any criteria, any document) Finds a single document and replaces it.
`any` | findOneAndUpdate(any criteria, any operation) Updates a single document found by a designated criteria.
`string` | getCollectionName()
`string` | getDbCollection()
`any` | getIndexInfo() Returns an array of object maps for all of the indexes in the collection.
`string` | getJLoader()
`string` | getMongoUtil()
`any` | insertMany(array docs) Inserts an array of document.
`any` | insertOne(any document) Inserts a single document.
`any` | mapReduce(string map, string reduce) Performs a Map-Reduce operation on the collection.
`any` | onDIComplete()
`any` | remove(any criteria, [any multiple='true']) Utility method which emulates the remove() method available in the v2 Mongo java drivers.
`any` | replaceOne(any criteria, any document) Replaces one document found by a designated criteria .
`any` | save(any document, any upsert='false') Generic Save Function - Uses findOneAndReplace().
`any` | setCollectionName(any collectionName)
`any` | setDbCollection(any dbCollection)
`any` | setJLoader(any jLoader)
`any` | setMongoUtil(any MongoUtil)
`private any` | toMongo(any obj) Utility facade for Mongo.
`private any` | toMongoDocument(any doc) Utility facade for Mongo.
`any` | updateMany(any criteria, any operation) Updates multiple documents found by a designated criteria .
`any` | updateOne(any criteria, any operation) Updates one document found by a designated criteria .

Methods inherited from class `lucee.Component`
None

Constructor Detail

### init

`public init([any dbCollectionInstance])`

Constructor - Must be manually instantiated with the Mongo Collection Object

Parameters:
  `dbCollectionInstance`

Property Detail

### collectionName

`property any collectionName`

The name of our collection

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

### dbCollection

`property any dbCollection`

The native java Collection Object

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

### MongoUtil

`property any MongoUtil`

Mongo Utils

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

Method Detail

### aggregate

`public any aggregate([struct criteria], struct group, [struct projection], [any sort], [any groupMatch])`

Performs an aggregation operation on the collection using match or projection
See https://docs.mongodb.org/manual/aggregation/ for more information and commands

Parameters:
  `criteria`
  `group`
  `projection`
  `sort`
  `groupMatch`

### aggregation

`public any aggregation(array command)`

Parameters:
  `command`

### bulkWrite

`public any bulkWrite()`

Facade for the driver's bulkWrite() method
NOTE: Not implemented as CF native at the present time. Operations will need to be performed using the java arguments: http://api.mongodb.org/java/current/com/mongodb/DBCollection.html

### count

`public any count([any criteria='[runtime expression]'])`

Counts the number of records, by restriction or in total

Parameters:
  `criteria`

### createGeoIndex

`public any createGeoIndex(string field, any options='[runtime expression]', string geoType='2dsphere')`

Creates a geospatial index

Parameters:
  `field`
  `options`
  `geoType`

### createIndex

`public any createIndex(any operation, any options='[runtime expression]')`

Creates a standard index

Parameters:
  `operation`
  `options`

### createIndexes

`public any createIndexes(array indexes)`

Creates multiple indexes

Parameters:
  `indexes`

### deleteMany

`public any deleteMany(any criteria='[runtime expression]')`

Deletes many documents by criteria

Parameters:
  `criteria`

### deleteOne

`public any deleteOne(any criteria)`

Deletes a single document by criteria

Parameters:
  `criteria`

### distinct

`public any distinct(string fieldName, [struct criteria='[runtime expression]'])`

Returns the list of distinct values for a specified field name

Parameters:
  `fieldName`
  `criteria`

### drop

`public any drop()`

Drops the collection

### dropIndex

`public any dropIndex([string indexName], [any criteria])`

Drops an index Either a name or a criteria to search the existing indexes may be specified

Parameters:
  `indexName`
  `criteria`

### dropIndexes

`public any dropIndexes()`

Drops all indexes in a collection

### find

`public any find(any criteria='[runtime expression]', struct options='[runtime expression]')`

Facade for the drivers find method. Encapuslates the result with a number of utility methods

Parameters:
  `criteria`
  `options`

### findById

`public any findById(any id)`

Finds a single document by its _id

Parameters:
  `id`

Returns:
  mixed result|null Returns the result if found or returns null if the document was not found

### findOneAndDelete

`public any findOneAndDelete(struct criteria, [any options])`

Finds one document and deletes it

Parameters:
  `criteria`
  `options`

### findOneAndReplace

`public any findOneAndReplace(any criteria, any document)`

Finds a single document and replaces it

Parameters:
  `criteria`
  `document`

### findOneAndUpdate

`public any findOneAndUpdate(any criteria, any operation)`

Updates a single document found by a designated criteria

Parameters:
  `criteria`
  `operation`

### getCollectionName

`public string getCollectionName()`

### getDbCollection

`public string getDbCollection()`

### getIndexInfo

`public any getIndexInfo()`

Returns an array of object maps for all of the indexes in the collection

### getJLoader

`public string getJLoader()`

### getMongoUtil

`public string getMongoUtil()`

### insertMany

`public any insertMany(array docs)`

Inserts an array of document

Parameters:
  `docs`

### insertOne

`public any insertOne(any document)`

Inserts a single document

Parameters:
  `document`

### mapReduce

`public any mapReduce(string map, string reduce)`

Performs a Map-Reduce operation on the collection
See Mongo Documentation for more information on Map-Reduce functionality

Parameters:
  `map`
  `reduce`

### onDIComplete

`public any onDIComplete()`

### remove

`public any remove(any criteria, [any multiple='true'])`

Utility method which emulates the remove() method available in the v2 Mongo java drivers

Parameters:
  `criteria`
  `multiple`

### replaceOne

`public any replaceOne(any criteria, any document)`

Replaces one document found by a designated criteria
NOTE: facade for findOneAndReplace()

Parameters:
  `criteria`
  `document`

### save

`public any save(any document, any upsert='false')`

Generic Save Function - Uses findOneAndReplace()

Parameters:
  `document`
  `upsert`

### setCollectionName

`public any setCollectionName(any collectionName)`

Parameters:
  `collectionName`

### setDbCollection

`public any setDbCollection(any dbCollection)`

Parameters:
  `dbCollection`

### setJLoader

`public any setJLoader(any jLoader)`

Parameters:
  `jLoader`

### setMongoUtil

`public any setMongoUtil(any MongoUtil)`

Parameters:
  `MongoUtil`

### toMongo

`private any toMongo(any obj)`

Utility facade for Mongo.Util.toMongo

Parameters:
  `obj`

### toMongoDocument

`private any toMongoDocument(any doc)`

Utility facade for Mongo.Util.toMongoDocument

Parameters:
  `doc`

### updateMany

`public any updateMany(any criteria, any operation)`

Updates multiple documents found by a designated criteria
NOTE: facade for findOneAndUpdate()

Parameters:
  `criteria`
  `operation`

### updateOne

`public any updateOne(any criteria, any operation)`

Updates one document found by a designated criteria
NOTE: facade for findOneAndUpdate()

Parameters:
  `criteria`
  `operation`