meow
meow

Reputation: 28174

Mongoid syntax for querying based on several sets of attributes

Assuming I want to get 3 documents which fit one of these attributes

Class Question:

name=>a, topic=>b
name=>c, topic=>d
name=>e, topic=>f

What is the appropriate syntax for mongoid to get these?

Upvotes: 0

Views: 102

Answers (1)

Voldy
Voldy

Reputation: 12868

According to mongoid query syntax:

Model.any_of({:name => a, :topic => b}, 
             {:name => c, :topic => d}, 
             {:name => e, :topic => f})

Upvotes: 1

Related Questions