You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying this
return Model.count({distinct:'col_name',where:{some condition}});
It isn't working and the corresponding sql query that it produces is:
SELECT count(DISTINCT(*)) AS count FROM mail_box AS mail_box WHERE mail_box.to_username = 'nikhil9999';
This should only need a small amount of code + test, so if you have the time it'll be quicker if you fix it yourself and provide a PR than waiting till someone from core has time to do it
@janmeier I've done it using literal. Thanks anyways.
And also can i use diistinct along with include in findAll?some thing like this?
return Mailbox.findAll({DISTINCT:'from_username',where:{to_username:username},include:[{model:Profile,required:true}]});
Actually i wanted to retrieve all the users who have sent message to the specific user along with their info from profile table. So is it any way I can do this?
Maybe, but I have no idea what your schema looks like. Also, that is probably better suited as a SO / google groups / IRC question - let's keep this issue restricted to count
Activity
abhinav76 commentedon Sep 6, 2015
@janmeier ?
janmeier commentedon Sep 7, 2015
You're not going to get a response faster by pinging people - we'll respond when we have the time :)
Currently specifying the column is not supported, so tagging this as a feature request
[-]DISTINCT with count[/-][+]Specify the column for .count[/+]janmeier commentedon Sep 7, 2015
This should only need a small amount of code + test, so if you have the time it'll be quicker if you fix it yourself and provide a PR than waiting till someone from core has time to do it
abhinav76 commentedon Sep 8, 2015
@janmeier I've done it using literal. Thanks anyways.
And also can i use diistinct along with include in findAll?some thing like this?
return Mailbox.findAll({DISTINCT:'from_username',where:{to_username:username},include:[{model:Profile,required:true}]});
abhinav76 commentedon Sep 10, 2015
also if I am able to include more than 1 table in the above query but the they should all be distinct from_username?
janmeier commentedon Sep 10, 2015
No, distinct is only supported for count and other aggregations
I'm not sure what you mean by your second question?
abhinav76 commentedon Sep 10, 2015
Actually i wanted to retrieve all the users who have sent message to the specific user along with their info from profile table. So is it any way I can do this?
janmeier commentedon Sep 10, 2015
Maybe, but I have no idea what your schema looks like. Also, that is probably better suited as a SO / google groups / IRC question - let's keep this issue restricted to
count