Class: BSON::MaxKey

Inherits:
Object
  • Object
show all
Defined in:
lib/bson/types/min_max_keys.rb

Overview

A class representing the BSON MaxKey type. MaxKey will always compare greater than all other BSON types and values.

Examples:

Sorting (assume @numbers is a collection):


>> @numbers.save({"n" => Mongo::MaxKey.new})
>> @numbers.save({"n" => 0})
>> @numbers.save({"n" => 5_000_000})
>> @numbers.find.sort("n").to_a
=> [{"_id"=>4b5a050c238d3bace2000004, "n"=>0},
    {"_id"=>4b5a04e6238d3bace2000002, "n"=>5_000_000},
    {"_id"=>4b5a04ea238d3bace2000003, "n"=>#<Mongo::MaxKey:0x1014ef410>},
   ]

Instance Method Summary collapse

Instance Method Details

#==(obj) ⇒ Object


32
33
34
# File 'lib/bson/types/min_max_keys.rb', line 32

def ==(obj)
  obj.class == MaxKey
end