struct Mongo::ReadPreference

Overview

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

See: the official documentation.

Included Modules

Defined in:

cryomongo/read_preference.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(mode : String, tags : Array(BSON)? = nil, max_staleness_seconds : Int32? = nil, hedge : BSON? = nil) #

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

def self.from_bson(bson : BSON) #

NOTE See self.new.


Instance Method Detail

def clone #

def copy_with(mode _mode = @mode, tags _tags = @tags, max_staleness_seconds _max_staleness_seconds = @max_staleness_seconds, hedge _hedge = @hedge) #

def hedge : BSON? #

def max_staleness_seconds : Int32? #

def mode : String #

def tags : Array(BSON)? #

def to_bson(bson = BSON.new) #

Converts to a BSON representation.

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