Skip to content

Miscellaneous

findOrCreateBy[Property]()

findOrCreateBy[Property]() — returns any

Returns the object or creates a new one if it wasn’t found.

NameTypeRequiredDefaultDescription
savebooleanyestruePassing in false will create the object without saving it to the database.
// Return the first object that matches "Timberlake" in the last name column. If there is no match, create a new one and set firstName to "Justin".
newArtist = model("artist").findOrCreateByLastName(lastName="Timberlake", firstName="Justin");