sails-hook-sequelize icon indicating copy to clipboard operation
sails-hook-sequelize copied to clipboard

Feature: Shared model definitions

Open Damienmarble opened this issue 5 years ago • 4 comments

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.

Damienmarble avatar Feb 15 '19 20:02 Damienmarble

Seems that this work is not finished yet...

KSDaemon avatar Feb 20 '19 13:02 KSDaemon

I'm looking at why the tests succeed locally but fail in travis.

Damienmarble avatar Feb 20 '19 15:02 Damienmarble

Coverage Status

Coverage decreased (-19.2%) to 71.138% when pulling 2da50be089c67a09efc013d879745ce838531429 on ThisIsNoZaku:feature/shared_model_definitions into fd6141125ade55b22c8044bfbe151f9bf867051d on KSDaemon:master.

coveralls avatar Mar 21 '19 21:03 coveralls

I've refactored tests heavily. So, please, pull updates from master into your code

KSDaemon avatar Oct 26 '19 14:10 KSDaemon