Set up the methods for storing and retrieving models on the Bookshelf instance.
Check the collection or module caches for a Model or Collection constructor, returning if the input is not an object. Check for a collection first, since these are potentially used with *-to-many relation. Otherwise, check for a registered model, throwing an error if none are found.
Re-implement the Bookshelf.Model
relation methods to include a check for the registered model.
The first argument is always a model, so resolve it and call the original method.
morphTo
takes the relation name first, and then a variadic set of models so we
can't include it with the rest of the relational methods.
The through
method exists on the Collection as well, for hasMany
/ belongsToMany
through relations.
Registry Plugin - Create a central registry of model/collection constructors to
help with the circular reference problem, and for convenience in relations.