Model Configuration
sharedModel()
Signature
Section titled “Signature”sharedModel() — returns void
Available in: model
Category: Multi-Tenancy
Description
Section titled “Description”Marks this model as shared — it will always use the default application datasource
even when a tenant is active. Use this for models like Tenant, Plan, or any
lookup table that lives in the central database rather than per-tenant databases.
Examples
Section titled “Examples”// 1. Mark the Tenant model as shared so it always reads from the central database
// models/Tenant.cfc
component extends="Model" {
function config() {
sharedModel();
}
}
// 2. Use sharedModel() for lookup tables that live in the central database,
// not in per-tenant databases
// models/Plan.cfc
component extends="Model" {
function config() {
sharedModel();
// All finder calls on Plan will use the default application datasource
// regardless of which tenant is currently active.
}
}