Alternative to skip and limit for mongoose pagination with arbitrary sorting
i don't think you can do this.
but in my opinion the best way is to build you query depending on your req.sort var.for example (it's written in coffescript)
userSort = {name:1} if req.sort? and req.sort="name"userSort = {date:1} if req.sort? and req.sort="date"userSort = {number:1} if req.sort? and req.sort="number"find {}, null , {skip : 0 , limit: 0, sort : userSort } , (err,results)->