getMongoService

Returns a MongoDB client object for the named MongoDB datasource. Call db(name) on the result to get a database object, and then work with its collections. Define the datasource in Application.cfc (in this.datasources with type="mongodb") or in the ColdFusion Administrator under NoSQL Data Sources.

getMongoService(config) → returns any

This function requires Adobe ColdFusion 2021 and up.  Not supported on Lucee, etc.

Argument Reference

config string
Required

Name of a MongoDB datasource defined in Application.cfc or the ColdFusion Administrator.

Compatibility

ColdFusion:

Version 2021+ Requires the mongodb package

Links more information about getMongoService

Examples
Sample code invoking the getMongoService function

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub