dchester / epilogue

Create flexible REST endpoints and controllers from Sequelize models in your Express app
846 stars 115 forks source link

Passing values when using scopes #204

Open SamD opened 7 years ago

SamD commented 7 years ago

As mentioned in the Sequelize documentation here http://docs.sequelizejs.com/en/latest/api/model/#scopeoptions-model

You can have scope functions with parameters.

e.g. complexFunction: function(email, accessLevel) { return { where: { email: { $like: email }, accesss_level { $gte: accessLevel } } } }

then use it like

Model.scope({ method: ['complexFunction' 'dan@sequelize.com', 42]}).findAll()

Since there is no way to currently query based on a value and an associated value I figured I could create a scope; however, epilogue only appears to be able to take a scope name and no parameters.

Is this possible?

G07cha commented 7 years ago

Sequelize actually supports using multiple scopes at once, so I think it also should be considered before implementing this feature.