-
Notifications
You must be signed in to change notification settings - Fork 5
1. Installation & Configuration
Cavan Vannice edited this page Mar 6, 2024
·
3 revisions
-
Install MongoDB and start up an instance of
mongod
or sign up for a free account with a third party DB service like MongoLab - Create a Coldbox application (
box install coldbox && box coldbox create app
) or use an existing one - With CommmandBox just type
box install cbmongodb
from the root of your project. - Add your settings (with your own config) to config/Coldbox.cfc
Localhost Example Without Authentication
MongoDB = {
//an array of servers to connect to
hosts= [
{
serverName='127.0.0.1',
serverPort='27017'
}
],
//The default database to connect to
db = "mydbname",
//whether to permit viewing of the API documentation
permitDocs = true,
//whether to permit unit tests to run
permitTests = true,
//whether to permit API access to the Generic API (future implementation)
permitAPI = true
};
See Advanced Connections for configuration options using authentication, clustering and additional options.
- Extend your models to use
cbmongodb.models.ActiveEntity
(orcbmongodb.models.GEOEntity
), add your collection component attribute and, optionally, a database attribute - if not specified, the database from your configuration will be used
Now all of our operations will be performed on the "peoplecollection" collection (which will be created if it doesn't exist).
component name="MyDocumentModel" extends="cbmongodb.models.ActiveEntity" collection="peoplecollection" database="MyNewDatabase" accessors=true{
}