如何查询Mongoid,' where not not null'?

时间:2015-02-24 10:12:03

标签: ruby-on-rails mongoid

如何查询Mongoid,'where not not'?例如

where('comment_id IS NOT NULL')

如何使用mongoid?

2 个答案:

答案 0 :(得分:9)

您可以使用$ne

撰写
where(:comment_id.ne => nil)

相关documentation of queries

答案 1 :(得分:2)

试试这个

Model.where(:comment_id.exists => true)