基于数组索引

时间:2015-12-11 10:55:57

标签: javascript arrays mongodb sorting underscore.js

我有来自anotherCollection的id数组..在我做了很多计算之后,我得到了:

idSortByRank = ["cxwMoC3k6kpf4mr5o","HFYjC5nuT9hKhdyFC","GiM7NCLjck6Pet8Wm"]

我需要从idSortByRank排序/索引的MyCollection的mongodb集合中返回对象,如下所示:

//expected result should index/sort the same as idSortByRank

[
{"_id": "cxwMoC3k6kpf4mr5o", other field},
{"_id": "HFYjC5nuT9hKhdyFC", other field},
{"_id": "GiM7NCLjck6Pet8Wm", other field}
]

我这样做但没有按预期排序:

MyCollection.find({_id:{$in:idSortByRank}});

我在rank

中没有MyCollection字段

非常感谢你......

1 个答案:

答案 0 :(得分:1)

您可以使用给定数组sudo chgrp procmod /path/to/gdb sudo chmod g+s /path/to/gdb 的索引进行排序。



idSortByRank




相关问题