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)

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

[View source]

Class Method Detail

def self.from_bson(bson : BSON) #

NOTE See self.new.


[View source]

Instance Method Detail

def alternate : String | Nil #

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


[View source]
def alternate=(alternate : String | Nil) #

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


[View source]
def backwards : Bool | Nil #

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


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


[View source]
def case_first : String | Nil #

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


[View source]
def case_first=(case_first : String | Nil) #

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


[View source]
def case_level : Bool | Nil #

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


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

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


[View source]
def locale : String #

The ICU locale.


[View source]
def locale=(locale : String) #

The ICU locale.


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


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


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


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


[View source]
def numeric_ordering : Bool | Nil #

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


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

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


[View source]
def strength : Int32 | Nil #

The level of comparison to perform.


[View source]
def strength=(strength : Int32 | Nil) #

The level of comparison to perform.


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

Converts to a BSON representation.

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

[View source]