hyperrjas
hyperrjas

Reputation: 10744

How to make a query with AND condition in mongoid

How can I make a query with AND condition in Mongoid?

Upvotes: 4

Views: 5431

Answers (2)

Aaron
Aaron

Reputation: 889

Also, you can chain things using .and(other_thing:'value')

For instance, Model.where(awesome:true).and(other_thing:true)

Upvotes: 2

Travis
Travis

Reputation: 10567

You can chain where statements or include multiple conditions to the where call.

Model.where(condition_a: :a, condition_b: :b).all

or

Model.where(condition_a: :a).where(condition_b: :b).all

Upvotes: 15

Related Questions