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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -