node.js - change the order of mongoose result with the given array -
i having nodejs model,
itemmodel.find({deleted:false},function(error,response){ }); // here getting response,
[{_id:'3221xxx',status:"b"}, {_id:'3221xxx',status:"a"}, {_id:'3221xxx',status:"d"}, {_id:'3221xxx',status:"c"} ] // have rule in array e.g: ['a','b','c','d'] in order, have list data based on array. this,
[{_id:'3221xxx',status:"a"}, {_id:'3221xxx',status:"b"}, {_id:'3221xxx',status:"c"}, {_id:'3221xxx',status:"d"} ] please me better & easy way
Comments
Post a Comment