Skip to content

Global Helpers

model()

model() — returns any

Available in: controller, model, test, migrator, migration, tabledefinition Category: Miscellaneous Functions

Returns a reference to the requested model so that class level methods can be called on it.

NameTypeRequiredDefaultDescription
namestringyesName of the model to get a reference to.
// The `model("author")` part of the code below gets a reference to the model from the application scope, and then the `findByKey` class level method is called on it
authorObject = model("author").findByKey(1);