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, case_first : String? = nil, strength : Int32? = 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? #

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


def alternate=(alternate : String?) #

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


def backwards : Bool? #

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


def backwards=(backwards : Bool?) #

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


def case_first : String? #

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


def case_first=(case_first : String?) #

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


def case_level : Bool? #

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


def case_level=(case_level : Bool?) #

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? #

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?) #

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


def normalization : Bool? #

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?) #

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? #

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


def numeric_ordering=(numeric_ordering : Bool?) #

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


def strength : Int32? #

The level of comparison to perform.


def strength=(strength : Int32?) #

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