Merged
Conversation
7b0bcdb to
6174a7c
Compare
test/integration/hooks.test.js
Outdated
Contributor
There was a problem hiding this comment.
You can clean up assertions a bit by using stuff like:
return expect(this.User.count({where: {username: 'joe'}})).to.eventually.equal(1);
return expect(this.User.count({where: {username: 'joe'}})).to.be.rejectedWith('Oops!');
Contributor
Author
There was a problem hiding this comment.
Thanks for the tip. Clean up done!
Contributor
|
LGTM, @janmeier? |
janmeier
added a commit
that referenced
this pull request
Feb 21, 2016
Member
|
Yep, LGTM as well - thanks a lot @matthewheck , and sorry for leaving you waiting for so long |
|
BeforeCount is not in the documentation: http://docs.sequelizejs.com/en/v3/api/hooks/ |
|
Update: still no mention in the docs http://docs.sequelizejs.com/ This is a cool feature that merits documenting. How can I help? ping @sdepold |
|
Why not just firing beforeFind hook? It seems odd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This provides a solution to #4683. This provides a beforeCount hook to the count query, allowing for the user to change the options of count before the database is queried.
I attempted to add an afterCount hook but, because the count is not attached to the model itself, changing it after the database return would require more substantial (probably breaking) changes. Additionally, can't think of a good use case for changing the count after we have queried the database.
Long time user, first time contributor. Hoping to give back more to this great community!