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
{{ message }}
Repository navigation
I wonder how can i perform an sql query which joins another table for it's count() column #2353
@janmeier
Additional, what if I want to set alias to the count attribute, I tried {model: sequelize.fn('count', sequelize.col('companies.area')), as: 'areas'} which does not work, tks
Almost correct, I'd say wrap the whole .fn in an array instead of the col attributes: ['id', [sequelize.fn('count', sequelize.col('companies.area')), 'areas']],
Activity
janmeier commentedon Sep 25, 2014
jiananshi commentedon Sep 25, 2014
I just learned that this function can use here in this way, tks very much! @janmeier
jiananshi commentedon Sep 26, 2014
@janmeier
Additional, what if I want to set alias to the count attribute, I tried
{model: sequelize.fn('count', sequelize.col('companies.area')), as: 'areas'}which does not work, tksjiananshi commentedon Sep 26, 2014
Finally I got ya searching from issuses:
attributes: ['id', sequelize.fn('count', [sequelize.col('companies.area')), 'areas']],janmeier commentedon Sep 26, 2014
Almost correct, I'd say wrap the whole .fn in an array instead of the col
attributes: ['id', [sequelize.fn('count', sequelize.col('companies.area')), 'areas']],jiananshi commentedon Sep 26, 2014
@janmeier
tks, man.
I'm afraid I may take a look at the source code after few days, just guessing usage of apis here and there feels awful :(
janmeier commentedon Sep 26, 2014
Have you seen the API reference :) ? https://github.com/sequelize/sequelize/wiki/API-Reference
jiananshi commentedon Sep 26, 2014
I do, but some APIS are not fully explained, I try to copy from other APIS behaviors but usually fails.. More demos will be helpful, I think
janmeier commentedon Sep 26, 2014
Which API's specifically - we should definitely improve on that then?
janmeier commentedon Sep 26, 2014
Any APIs in particular - we could try to imrpove on that. Feel free to open issues on https://github.com/sequelize/doc for missing documentation