Orator To Masonite ORM
Orator To Masonite ORM Guide
This guide will explain how to move from Orator to Masonite ORM. Masonite ORM was made to be pretty much a straight port of Orator but allow the Masonite organization complete creative control of the ORM.
Orator has since been abandoned and Masonite needed a good ORM to keep fresh features and security up to date with the ORM.
Before moving your project over to Masonite ORM please keep in mind some features are not (_at least currently)_ ported over from Orator. These are features that may be ported over in the future.
This list is a continuously evolving list of features and anything we develop will be removed from the list. These features are planned but not yet finished.
Currently these features are:
has one through relationship
If you are using Masonite 2 then you will not be able to upgrade to Masonite ORM because of version conflicts between Masonite and Masonite 2 ORM.
Config
The configuration dictionary between Orator and Masonite ORM is identical. The only difference is that Masonite ORM requires a config/database.py
file whereas Orator was optional and needed to be explicitly specified in several places like commands.
If you are coming from Masonite already then don't worry, this file is already there. If not you will need to create this config/database.py
file.
This is an example of a Masonite ORM config dictionary:
The other thing you will need to do is change the resolver classes. Orator has a configuration structure like this:
Masonite ORM those same resolver classes looks like this:
Models
Models are identical but the imports are different. Orator requires you to set the model resolver from the configuration file and then you import that model.
In Masonite ORM you import the model directly:
Scopes
Scopes are also identical but the import changes:
Fetching builder relations
In Orator you could do this:
This would delay the relationship call and would instead append the builder before returning the result.
The above call in Masonite ORM becomes:
Last updated