0

I need to query my mongodb collection for anything that has a foreman equal to nil or ""

this is what I have so far... but I dont know how to alter it to accept nil and "", I found this, but its SUPER not clear and I havent been able to make it work

OR query matching nil or "" with Mongoid still matches ""?

where(foreman: '', status: 'Active').order_by(first_name: :asc)
Community
  • 1
  • 1
alilland
  • 2,039
  • 1
  • 21
  • 42

1 Answers1

0

solved, the answer was using any_of instead of where

any_of({foreman: nil, status: 'Active'}, {foreman: '', status: 'Active'}).order_by(first_name: :asc)

more info was found here: Mongoid OR query syntax

Community
  • 1
  • 1
alilland
  • 2,039
  • 1
  • 21
  • 42