March 14, 2022
Mongodb
Comments
(1)
March 14, 2022
Mongodb
Newbie 2 posts
Followers: 0 people
(1)

Can anyone give a simple example of how to config a NoSQL database for mongodb.

1 Comment
2022-03-16 14:38:22
2022-03-16 14:38:22

Do you mean as of CF2021, which added formal support for mongodb as a datasource? If so, it’s NOT in the normal page of CF DSNs: it’s in a page next to it. Both are in the section (blue button on the left) for “Data & Services”, but the traditional one is in the page called “Data Sources”, while the one next to it (in the menu at the top of the page for this section) is called “NoSQL Data Sources”. And you will see that for now, the only option in the “Driver” drop-down is “MongoDB”. Once you enter a name and click “Add”, you will be shown a page full of Mongo config settings. (And like any CF datasource, you can also configure it entirely in your application.cfc with this.datasources.)

For more, see also the docs on the topic: https://helpx.adobe.com/coldfusion/using/integrate-coldfusion-mongodb.html, and also a brief blog post on it: https://coldfusion.adobe.com/2020/12/mongodb-integration-cf2021. Note that both go on to show as well the CFML you’d use to interact with mongodb.

Finally, if somehow you meant that you are NOT on CF2021, then you’d instead need to create a datasource using the “other” driver option in the CF “Data Sources” page, after obtaining and implementing a mongo jdbc driver. There are commercial (cdata) and open source (mongo-java-driver) variants. You’d then create a DSN using that driver, and using the JDBC url as suited to the specific driver. Here are discussions of each variant:

https://www.cdata.com/kb/tech/mongodb-jdbc-coldfusion-query.rst

https://stackoverflow.com/questions/36308764/how-to-use-mongodb-with-coldfusion 

Let us know if one of the various options above gets you going.

Like
(1)
Add Comment