Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow scope() to be used for operations #130

Closed
bparise opened this issue Jun 23, 2017 · 3 comments
Closed

Allow scope() to be used for operations #130

bparise opened this issue Jun 23, 2017 · 3 comments

Comments

@bparise
Copy link
Contributor

bparise commented Jun 23, 2017

I want to scope() records through hooks. I use scopes frequently in my API to allow users with certain roles access to mutate objects. I know I can just where={}, but scopes are way more convenient and centralized to the model.

Would be nice to:

hook => {
  hook.params.sequelize.scope = 'approved'
  return Promise.resolve(hook)
}

Right now, this setting is ignored because you have to scope records like:

Model.scope('approved').findAll()...

I can do a PR for this, just let me know!

let Model = this.Model
if (params.scope) {
  Model = this.Model.scope(params.scope)
}
@DesignByOnyx
Copy link
Contributor

@bparise - If you want to submit a PR. I will endorse it. This would be a great feature! If you don't have time I will try and squeeze it in - let me know. If you want to do it, make sure to write tests and update the docs. You go to a particular page at https://docs.feathersjs.com/, then click the "Edit this page" link in the top.

@bparise
Copy link
Contributor Author

bparise commented Jul 21, 2017

Done! I'll update the documentation once the PR is officially accepted.

@daffl
Copy link
Member

daffl commented Jul 24, 2017

Closed via #142

@daffl daffl closed this as completed Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants