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)

[View source]
def self.new(j : Bool | Nil = nil, w : Int32 | Nil | String | Nil = nil, w_timeout : Int64 | Nil = nil) #

Create a WriteConcern instance.


[View source]

Class Method Detail

def self.from_bson(bson : BSON) #

NOTE See self.new.


[View source]

Instance Method Detail

def j : Bool | Nil #

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


[View source]
def j=(j : Bool | Nil) #

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


[View source]
def to_bson(bson = BSON.new) #

Converts to a BSON representation.

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

[View source]
def unacknowledged? #

[View source]
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.


[View source]
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.


[View source]
def w_timeout : Int64 | Nil #

This option specifies a time limit, in milliseconds, for the write concern. wtimeout is only applicable for w values greater than 1.


[View source]
def w_timeout=(w_timeout : Int64 | Nil) #

This option specifies a time limit, in milliseconds, for the write concern. wtimeout is only applicable for w values greater than 1.


[View source]