Model Configuration
dataSource()
Signature
Section titled “Signature”dataSource() — returns void
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Use this method to override the data source connection information for this model.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
datasource | string | yes | — | The data source name to connect to. |
username | string | no | — | The username for the data source. |
password | string | no | — | The password for the data source. |
Examples
Section titled “Examples”// 1. Override the data source for a model (basic usage).
// In models/User.cfc
config() {
// Tell Wheels to use the data source named `users_source` instead of
// the default one whenever this model makes SQL calls.
dataSource("users_source");
}
// 2. Override the data source with explicit credentials.
// In models/LegacyOrder.cfc
config() {
dataSource(datasource="legacy_db", username="app_reader", password="s3cr3t");
}