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

Expose mongoose.Query._pre as public #9784

Closed
stalniy opened this issue Jan 8, 2021 · 2 comments
Closed

Expose mongoose.Query._pre as public #9784

stalniy opened this issue Jan 8, 2021 · 2 comments
Labels
new feature This change adds new functionality, like a new method or class
Milestone

Comments

@stalniy
Copy link

stalniy commented Jan 8, 2021

Do you want to request a feature or report a bug?

feature

What is the current behavior

mongoose.Query._pre undocumented and private

What is the expected behavior?

mongoose.Query._pre documented and public

Why?

I’m an author of casl (permission management system) and I wrote a plugin for mongoose which adds accessibleBy static method to model. This method returns accessible records from db based on user permissions.

There are cases when I can predict that there is no such records in db and instead of sending dummy query that returns no results, I’d like to throw an error that user doesn’t have permissions.

I can use pre exec hook on query to achieve this but currently it’s private and I don’t want to use private method which eventually may disappear without any notice in release

@stalniy
Copy link
Author

stalniy commented Jan 11, 2021

looks like I can just patch Query.exec method. As far as I see it's used as a gate for all db queries, right?

@vkarpov15 vkarpov15 added this to the 5.12 milestone Jan 13, 2021
@vkarpov15
Copy link
Collaborator

This is something we've been wanting to do for a while. We will look into this for our next minor release.

@IslandRhythms IslandRhythms added the new feature This change adds new functionality, like a new method or class label Jan 28, 2021
This was referenced Mar 11, 2021
This was referenced Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

No branches or pull requests

3 participants