-
Notifications
You must be signed in to change notification settings - Fork 362
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
feat: provide support for groupby #2175
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,6 +272,56 @@ describe('crud-with-options', function() { | |
User.find({limit: 3}); | ||
}); | ||
|
||
it('should allow filter with groupBy, count, max, min, sum & avg', function(done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add test cases for when there are other filter queries too and limit and offset is also provided ? Basically to confirm whether this feature works with other features together or not. And whether it has any impact there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @samarpanB. I have added one more test to verify the change with existing filters. |
||
User.find({ | ||
groupBy: ['vip'], | ||
count: 'vip', | ||
max: 'id', | ||
min: 'id', | ||
sum: 'id', | ||
avg: 'id', | ||
}, options, function(err, users) { | ||
should.not.exist(err); | ||
should.exist(users); | ||
users.length.should.be.above(0); | ||
users.forEach(user => { | ||
user.should.have.property('count', user.count); | ||
user.should.have.property('max'); | ||
user.should.have.property('min'); | ||
user.should.have.property('sum'); | ||
user.should.have.property('avg'); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should allow filter with groupBy, aggregate methods and other filters', function(done) { | ||
User.find({ | ||
groupBy: ['vip'], | ||
count: 'vip', | ||
max: 'id', | ||
min: 'id', | ||
sum: 'id', | ||
avg: 'id', | ||
limit: 1, | ||
fields: ['name', 'id'], | ||
}, options, function(err, users) { | ||
should.not.exist(err); | ||
should.exist(users); | ||
users.length.should.be.equal(1); | ||
users.forEach(user => { | ||
user.should.have.property('count', user.count); | ||
user.should.have.property('max'); | ||
user.should.have.property('min'); | ||
user.should.have.property('sum'); | ||
user.should.have.property('avg'); | ||
user.should.have.property('name'); | ||
user.should.have.property('id'); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should skip trailing undefined args', function(done) { | ||
User.find({limit: 3}, function(err, users) { | ||
should.exists(users); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will require support for connector too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. And it's implemented here.