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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -