如何按ids
查询一批文件(其中的元素可能重复),例如
var ids = [
"57470bda627fe714555d96d1", "57470bda627fe714555d2401",
"57470bda627fe714555d9922" , "57470bda627fe714555d2401",
"57470bda627fe714555d2401"
];
var results = db.collection('Person').find(query_containing_ids);
//The desired results
results = [{_id:"57470bda627fe714555d96d1", name:"xxxx"},
{_id:"57470bda627fe714555d2401", name:"yyy"},
{_id:"57470bda627fe714555d96d1", name:"xxxx"},
{_id:"57470bda627fe714555d2401", name:"yyyy"},
{_id:"57470bda627fe714555d2401", name:"yyyy"},]
查询结果应与ids
的顺序相同,结果中可能存在重复的对象。
Mongodb可以吗?