Return to v2.1 docs

setPrimaryKey()


Model Configuration Miscellaneous Functions void model


Allows you to pass in the name(s) of the property(s) that should be used as the primary key(s). Pass as a list if defining a composite primary key. This function is also aliased as setPrimaryKeys().

Name Type Required Default Description
property string Yes Property (or list of properties) to set as the primary key.
// In `models/User.cfc`, define the primary key as a column called `userID`.
function config(){
	setPrimaryKey("userID");
}

Related Functions

Miscellaneous Functions