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

Fixed $and condition being overridden on queries #273

Merged
merged 1 commit into from
Mar 13, 2020

Conversation

m-weeks
Copy link
Contributor

@m-weeks m-weeks commented Mar 12, 2020

Fixes #272

In order to test I needed to check the "private" attribute _conditions on the query. This probably isn't preferable but I wasn't able to think of another way. If you happen to know of one I'll gladly make the change

@stalniy
Copy link
Owner

stalniy commented Mar 13, 2020

There was getQuery() method in mongoose.Query which should give you the same value

@stalniy stalniy force-pushed the fix-and-condition-override branch from 253310c to 4a5cbcf Compare March 13, 2020 07:54
@stalniy
Copy link
Owner

stalniy commented Mar 13, 2020

I did some minor changes to your code, removed tests that tests implementation and left only those that test behavior. Also used instanceof to check that this is an instance of Query.

Everything else is good! Thank you very much for the contribution!

@stalniy stalniy merged commit c13300f into stalniy:master Mar 13, 2020
@m-weeks
Copy link
Contributor Author

m-weeks commented Mar 13, 2020

@stalniy Thanks! I was searching the mongoose docs for a method that could get the conditions, must've just missed it. Glad you knew about it!

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

Successfully merging this pull request may close these issues.

@casl/mongoose should use .and for adding the condition instead of .where when called on a Query
2 participants