I am trying to get https://github.com/jarrodconnolly/sequelize-slugify to work within my Trails setup, but I can't see a way of accessing the Model that is created by Sequelize inside of the Trails model. The plugin example says I need to do something like:
SequelizeSlugify.slugifyModel(SequelizeModelHere, {
source: ['title'],
suffixSource: ['year']
});
I noticed that trails creates a Sequelize model and adds it to the service locator under this.app.orm[model.globalId]
, I however can't access this inside of the Trails model itself as it would not have been created by then. I wanted to do this all inside of the model itself, but if there is no way of doing this, I will do it in a Service instead.
You're right, currently there no way of doing it under the model itself because they are just the definition used to create the sequelize models.
What you can do is use trailpack-bootstrap to initialized them after everything is setup.
You should also create an issue under trailpack-sequelize to raise this limitation, I think it can be good to have such possibility and shouldn't be too hard to add :)