struct Mongo::WriteConcern

Overview

Write concern describes the level of acknowledgment requested from MongoDB for write operations to a standalone mongod or to replica sets or to sharded clusters.

In sharded clusters, mongos instances will pass the write concern on to the shards.

See: the official documentation

Included Modules

Defined in:

cryomongo/concerns.cr

Constructors

Class Method Summary

Instance Method Summary

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)

def self.new(j : Bool? = nil, w : Int32? | String? = nil, w_timeout : Int64? = nil) #

Create a WriteConcern instance.


Class Method Detail

def self.from_bson(bson : BSON) #

NOTE See self.new.


Instance Method Detail

def j : Bool? #

The j option requests acknowledgment from MongoDB that the write operation has been written to the on-disk journal.


def j=(j : Bool?) #

The j option requests acknowledgment from MongoDB that the write operation has been written to the on-disk journal.


def to_bson(bson = BSON.new) #

Converts to a BSON representation.

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

def unacknowledged? #

def w : Int32 | String | Nil #

The w option requests acknowledgment that the write operation has propagated to a specified number of mongod instances or to mongod instances with specified tags.


def w=(w : Int32 | String | Nil) #

The w option requests acknowledgment that the write operation has propagated to a specified number of mongod instances or to mongod instances with specified tags.


def w_timeout : Int64? #

def w_timeout=(w_timeout : Int64?) #