struct

Mongo::Collation

Inherits BSON::Serializable / Struct / Value / Object

Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.

See: the official documentation

Constructors

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
new(locale : String, case_level : Bool | Nil = nil, case_first : Nil | String = nil, strength : Int32 | Nil = nil, numeric_ordering = nil, alternate = nil, max_variable = nil, backwards = nil, normalization = nil)

Create a new Collation instance.

collation = Mongo::Collation.new(locale: "fr")
Source

Class methods

from_bson(bson : BSON)

NOTE: See self.new.

Source

Instance methods

alternate

Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.

Source
alternate=(alternate : String | Nil)

Field that determines whether collation should consider whitespace and punctuation as base characters for purposes of comparison.

Source
backwards

Flag that determines whether strings with diacritics sort from back of the string, such as with some French dictionary ordering.

Source
backwards=(backwards : Bool | Nil)

Flag that determines whether strings with diacritics sort from back of the string, such as with some French dictionary ordering.

Source
case_first

A field that determines sort order of case differences during tertiary level comparisons.

Source
case_first=(case_first : String | Nil)

A field that determines sort order of case differences during tertiary level comparisons.

Source
case_level

Flag that determines whether to include case comparison at strength level 1 or 2.

Source
case_level=(case_level : Bool | Nil)

Flag that determines whether to include case comparison at strength level 1 or 2.

Source
locale

The ICU locale.

Source
locale=(locale : String)

The ICU locale.

Source
max_variable

Field that determines up to which characters are considered ignorable when alternate: "shifted". Has no effect if alternate: "non-ignorable"

Source
max_variable=(max_variable : String | Nil)

Field that determines up to which characters are considered ignorable when alternate: "shifted". Has no effect if alternate: "non-ignorable"

Source
normalization

Flag that determines whether to check if text require normalization and to perform normalization. Generally, majority of text does not require this normalization processing.

Source
normalization=(normalization : Bool | Nil)

Flag that determines whether to check if text require normalization and to perform normalization. Generally, majority of text does not require this normalization processing.

Source
numeric_ordering

Flag that determines whether to compare numeric strings as numbers or as strings.

Source
numeric_ordering=(numeric_ordering : Bool | Nil)

Flag that determines whether to compare numeric strings as numbers or as strings.

Source
strength

The level of comparison to perform.

Source
strength=(strength : Int32 | Nil)

The level of comparison to perform.

Source
to_bson(bson = BSON.new)

Converts to a BSON representation.

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