Return to v2.3 docs


Model Object Miscellaneous Functions string model

Returns the value of the primary key for the object. If you have a single primary key named id, then someObject.key() is functionally equivalent to This method is more useful when you do dynamic programming and don't know the name of the primary key or when you use composite keys (in which case it's convenient to use this method to get a list of both key values returned).

Name Type Required Default Description
// Get an object and then get the primary key value(s)
employee = model("employee").findByKey(params.key);
val = employee.key();

Related Functions

Miscellaneous Functions