Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Created July 17, 2010 22:18
Show Gist options
  • Save bernerdschaefer/479896 to your computer and use it in GitHub Desktop.
Save bernerdschaefer/479896 to your computer and use it in GitHub Desktop.
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db('testing')
end
class Parent
include Mongoid::Document
field :name
collection.remove
end
Parent.create
Parent.create(:name => "John")
Parent.where(:name => nil).size # => 1
Parent.collection.find(:name => {'$in' => [nil]}).to_a.size # => 0
Parent.where(:name.in => [nil]).size # => 0
# mongo
# > use testing
# > db.parents.count({ name : { $in : [null] } }) # => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment