is there a preferred way to check for existing documents via mongoid?
if i do Model.find('id')', and the id is nil or the document doesn’t exist, it throws an exception… i want it to return an empty array.
if i do Model.where(:id => 'id'), and the id is nil, it returns all the documents… i also want it to return an empty array.
and then with Model.criteria(:id => 'id').to_a, for whatever reason never returns a result, even with a valid object id. not sure what is going on there…
but basically with activerecord i would just use the exists? finder method, so i am looking for the mongoid alternative.
In Mongoid 2.0, Following seems to do what you want: