-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
What am I doing wrong? This seems pretty basic. As in taken-from-origin-example basic.
#!/usr/bin/env ruby require "mongoid" Mongoid.configure do |config| config.connect_to "mongoid_test" end class A include Mongoid::Document field :name, type: String, default: "Dave" end A.delete_all A.create A.create A.create A.create name: "David" A.create name: "Tom" # `not` does not work for simple equality # contrary to example from http://mongoid.org/en/origin/docs/selection.html puts A.where(name: "Dave").map(&:name).join " " puts A.not.where(name: "Dave").map(&:name).join " " puts A.not.where(name: "Dave").selector.inspect puts A.where(:name.ne => "Dave").map(&:name).join " " puts A.where(:name => /^Dav/).map(&:name).join " " puts A.not.where(:name => /^Dav/).map(&:name).join " "
Output:
Dave Dave Dave Dave Dave Dave # should be David Tom {"name"=>"Dave"} # should be { "$not" => { "name" => "Dave" }} David Tom Dave Dave Dave David Dave Dave Dave David # should be Tom