Model Configuration
setPrimaryKeys()
Signature
Section titled “Signature”setPrimaryKeys() — returns void
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Alias for setPrimaryKey().
Use this for better readability when you’re setting multiple properties as the primary key.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
property | string | yes | — | Property (or list of properties) to set as the primary key. |
Examples
Section titled “Examples”// 1. In `models/Subscription.cfc`, define the primary key as a composite of `customerId` and `publicationId`.
component extends="Model" {
function config() {
setPrimaryKeys("customerId,publicationId");
}
}
// 2. In `models/OrderItem.cfc`, define a composite primary key using three columns.
component extends="Model" {
function config() {
setPrimaryKeys("orderId,productId,warehouseId");
}
}