Leverage CommandBox to install into your ColdBox app:
# Latest versioninstall cborm​# Bleeding Edgeinstall [email protected]
Lucee 5.x+
ColdFusion 2016+
Unfortunately, due to the way that ORM is loaded by ColdFusion, if you are using the ORM EventHandler or ActiveEntity
or any ColdBox Proxies that require ORM, you must create an Application Mapping in the Application.cfc
like this:
Application.cfc# In the pseudo constructorthis.mappings[ "/cborm" ] = COLDBOX_APP_ROOT_PATH & "modules/cborm";
The module registers a new WireBox DSL called entityservice
which can produce virtual or base orm entity services. Below are the injections you can use:
entityservice
- Inject a global ORM service
entityservice:{entityName}
- Inject a Virtual entity service according to entityName
Here are the module settings you can place in your ColdBox.cfc
under moduleSettings
-> cborm
structure:
config/ColdBox.cfcmoduleSettings = {cborm = {// Resource Settingsresources : {// Enable the ORM Resource Event LoadereventLoader : false,// Pagination max rowsmaxRows : 25,// Pagination max row limit: 0 = no limitmaxRowsLimit : 500},// WireBox Injection bridgeinjection = {// enable entity injection via WireBoxenabled = true,// Which entities to include in DI ONLY, if empty include all entitiesinclude = "",// Which entities to exclude from DI, if empty, none are excludedexclude = ""}}}
We have also integrated a UniqueValidator
from the validation module into our ORM module. It is mapped into WireBox as [email protected]
so you can use in your model constraints like so:
{ fieldName : { validator: "[email protected]" } }