struct

Mongo::ReadPreference

Inherits BSON::Serializable / Struct / Value / Object

The read preference describes how MongoDB clients route read operations to the members of a replica set.

See: the official documentation.

Constructors

new(mode : String, tags : Array(BSON) | Nil = nil, max_staleness_seconds : Int32 | Nil = nil, hedge : BSON | Nil = nil)
Source
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)
Source

Class methods

from_bson(bson : BSON)

NOTE: See self.new.

Source

Instance methods

clone
Source
copy_with(mode _mode = @mode, tags _tags = @tags, max_staleness_seconds _max_staleness_seconds = @max_staleness_seconds, hedge _hedge = @hedge)
Source
hedge
max_staleness_seconds
mode
tags
to_bson(bson = BSON.new)

Converts to a BSON representation.

user = User.new name: "John"
bson = user.to_bson
Source