2012-11-16 43 views
1

了一定的成绩,我通常使用:红宝石/ MongoDB的:排除在查找

@coll.find({"lang"=>@language,"description"=>@description,"location"=>@location},{:limit=>@results_needed}).to_a 

但有些时候,我有“_ids”的数组,我不希望被列入结果。有没有一种原生的方式来做到这一点?我一直在做一个破解.delete_if,但我想保持数据库尽可能多的工作。

+0

您正在使用哪个驱动程序/映射器? – HungryCoder

+0

我使用的是mongo gem –

回答

3

什么

@coll.find(:id.ne => array_of_ids) 

@coll.find(:id => {:$ne => array_of_ids}) 

Not equals in mongo mapper

+0

':$ ne'是一个有效的符号,如果字符串版本困扰你的话。 –

+0

@ muistooshort谢谢! – oldergod