使用给定数组更改mongoose结果的顺序

时间:2015-07-14 08:01:20

标签: node.js mongodb

我有Nodejs模型,

itemModel.find({deleted:false},function(error,response){

  });

//我在这里得到回复,

[{_id:'3221xxx',status:"b"},
 {_id:'3221xxx',status:"a"},
 {_id:'3221xxx',status:"d"},
 {_id:'3221xxx',status:"c"}
]

//我在数组中有规则,例如['a','b','c','d'],我必须根据这个数组列出数据。像这样,

[{_id:'3221xxx',status:"a"},
 {_id:'3221xxx',status:"b"},
 {_id:'3221xxx',status:"c"},
 {_id:'3221xxx',status:"d"}
]

请帮助我更好和更好简单的方法

0 个答案:

没有答案