struct Mongo::Session::ClusterTime
- Mongo::Session::ClusterTime
- Struct
- Value
- Object
Included Modules
- BSON::Serializable
- Comparable(Mongo::Session::ClusterTime)
Defined in:
cryomongo/sessions/sessions.crConstructors
-
.new(bson : BSON)
Allocate an instance and copies data from a BSON struct.
Class Method Summary
-
.from_bson(bson : BSON)
NOTE See
self.new
.
Instance Method Summary
-
#<=>(other : ClusterTime)
The comparison operator.
- #cluster_time : BSON::Timestamp
- #signature : Signature
-
#to_bson(bson = BSON.new)
Converts to a BSON representation.
Constructor Detail
def self.new(bson : BSON)
#
Allocate an instance and copies data from a BSON struct.
class User
include BSON::Serializable
property name : String
end
data = BSON.new
data["name"] = "John"
User.new(data)
Class Method Detail
Instance Method Detail
def <=>(other : ClusterTime)
#
Description copied from module Comparable(Mongo::Session::ClusterTime)
The comparison operator. Returns 0
if the two objects are equal,
a negative number if this object is considered less than other,
a positive number if this object is considered greater than other,
or nil
if the two objects are not comparable.
Subclasses define this method to provide class-specific ordering.
The comparison operator is usually used to sort values:
# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]
# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
def to_bson(bson = BSON.new)
#
Converts to a BSON representation.
user = User.new name: "John"
bson = user.to_bson