node.js - Sort by the association with populate -


i have articles , comments linked one-to-many association (an article can have many comments).

i obtain commented articles proceed :

function mostcommentedarticles () {   var deferred = q.defer();   article.find().populate('comments').sort('comments asc').exec(deferred.makenoderesolver());   return deferred.promise; } 

but, don't obtain expected result : doesn't sort @ (by comments or else)

is there other way proceed or issue?

thanks,

pierre

you pass in second parameter of .populate() this:

.populate('foo', { sort: 'comments asc' }).exec(...) 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -