vveare138
vveare138

Reputation: 104

How make a query in to Mongoid, 'where is not null'?

How make a query in to Mongoid, 'where is not null'?For example

where('comment_id IS NOT NULL')

how make it with mongoid?

Upvotes: 3

Views: 3385

Answers (2)

Amol Udage
Amol Udage

Reputation: 3075

You can try this

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

Upvotes: 3

Arup Rakshit
Arup Rakshit

Reputation: 118271

You can write using $ne

where(:comment_id.ne => nil)

Relevant documentation of queries.

Upvotes: 12

Related Questions