Tighten up some options.Model/Sequelize/getModel related code. #267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Firstly, some background:
feathers-sequelize allows for overriding of its getModel method
in order to let users implement their own model provider schemes;
Overriding getModel() in this way allows for a different Model to be programatically
provided any time getModel() is called.
This can allow for multi-tenancy setups where different customer models/databases
are used depending upon different criteria, such as what hostname they're connecting to,
where they are connecting from, or whatever the programmer desires.
Currently, the feathers-sequelize Service class requires that a single Model be provided
in the options passed to its constructor. The problem is, when using a getModel() override
as described above, a single Model is probably not known at the time that the feathers-sequelize
Service constructor is called.
Therefore, a Model probably shouldn't be required at construction time.
This changeset makes providing a Model optional, adds an alternative option attribute called 'Sequelize'
for providing the Sequelize class (which is currently used to derive the default Ops), and
adds some warning messages inside of the Model getter to dissaude usage of it altogether other than
for coverage tests, since using this getter doesn't allow for proper getModel() overriding.