Find documents including element in Array field with mongomapper?

半世苍凉 提交于 2019-12-05 13:32:04

In the current versions of MongoMapper, this will work:

MessageThread.where(:partecipant_ids => 15)

And this should work as well...

MessageThread.where(:partecipant_ids => [15])

...because plucky autoexpands that to:

MessageThread.where(:partecipant_ids => { :$in => [15] })

(see https://github.com/jnunemaker/plucky/blob/master/lib/plucky/criteria_hash.rb#L121)

I'd say take a look at your data and try out queries in the Mongo console to make sure you have a working query. MongoDB queries translate directly to MM queries except for the above (and a few other minor) caveats. See http://www.mongodb.org/display/DOCS/Querying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!