Mongohelp
Mongohelp

Reputation: 31

Not equals in mongo mapper

I'm trying to run a query where I want to ignore records with a certain email address...

@foo = Bar.all(:email => 'xxx') <--- Except I want to negate where this email address exists.

Please let me know how I can do it.

Thanks!

Upvotes: 3

Views: 2857

Answers (3)

Diwakar upadhyay
Diwakar upadhyay

Reputation: 434

@foo = Bar.all(:email => {"$ne" => "xxx"})

Upvotes: 0

Allan
Allan

Reputation: 661

Or

@foo = Bar.all(:email.ne => 'xxx')

Upvotes: 9

Daniel O&#39;Hara
Daniel O&#39;Hara

Reputation: 13438

Try:

@foo = Bar.all(:email => {"$ne" => "xxx"})

Upvotes: 6

Related Questions