sails-hook-sequelize
sails-hook-sequelize copied to clipboard
Feature: Shared model definitions
Description, Motivation and Context
Adds support for sharing model definitions between multiple sequelize datasources automatically.
What is the current behavior?
Models can only be created for a single datasource at a time.
What is the new behavior?
When multiple datasources are configured and the config/sequelize.js
property shareModelsAmongConnections
is true
, any models where the connection
property is not explicitly set will be added to all sequelize connections.
Additionally, if sails models are configured to expose models globally, the shared models can be access through the global model class through a property with the same name as the associated datasource. e.g. Model[datasourceName].someMethod()
What kind of change does this PR introduce?
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist:
- [x] My code follows the code style of this project.
- [x] I have added tests to cover my changes.
- [x] Overall test coverage is not decreased.
- [x] All new and existing tests passed.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
Seems that this work is not finished yet...
I'm looking at why the tests succeed locally but fail in travis.
Coverage decreased (-19.2%) to 71.138% when pulling 2da50be089c67a09efc013d879745ce838531429 on ThisIsNoZaku:feature/shared_model_definitions into fd6141125ade55b22c8044bfbe151f9bf867051d on KSDaemon:master.
I've refactored tests heavily. So, please, pull updates from master into your code