struct Mongo::Collation

Overview

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

See: the official documentation

Included Modules

Defined in:

cryomongo/collation.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(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")

Class Method Detail

def self.from_bson(bson : BSON) #

NOTE See self.new.


Instance Method Detail

def alternate : String | Nil #

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


def alternate=(alternate : String | Nil) #

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


def backwards : Bool | Nil #

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


def backwards=(backwards : Bool | Nil) #

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


def case_first : String | Nil #

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


def case_first=(case_first : String | Nil) #

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


def case_level : Bool | Nil #

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


def case_level=(case_level : Bool | Nil) #

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


def locale : String #

The ICU locale.


def locale=(locale : String) #

The ICU locale.


def max_variable : String | Nil #

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


def 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"


def 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.


def 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.


def numeric_ordering : Bool | Nil #

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


def numeric_ordering=(numeric_ordering : Bool | Nil) #

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


def strength : Int32 | Nil #

The level of comparison to perform.


def strength=(strength : Int32 | Nil) #

The level of comparison to perform.


def to_bson(bson = BSON.new) #

Converts to a BSON representation.

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