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
Post a Comment