Class: BSON::MinKey

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

Overview

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

Examples:

Sorting (assume @numbers is a collection):


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

Instance Method Summary collapse

Instance Method Details

#==(obj) ⇒ Object


52
53
54
# File 'lib/bson/types/min_max_keys.rb', line 52

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