collation property

CollationOptions? collation
finalinherited

Specifies the default collation for the collection or the view.

Specifies the default collation for the collection or the view. Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks.

If you specify a collation at the collection level:

  • Indexes on that collection will be created with that collation unless the index creation operation explicitly specify a different collation.
  • Operations on that collection use the collection’s default collation unless they explicitly specify a different collation.
  • You cannot specify multiple collations for an operation. For example, you cannot specify different collations per field, or if performing a find with a sort, you cannot use one collation for the find and another for the sort.

If no collation is specified for the collection or for the operations, MongoDB uses the simple binary comparison used in prior versions for string comparisons.

After you create the collection or the view, you cannot update its default collation.

For an example that specifies the default collation during the creation of a collection, see Specify Collation.

New in version 3.4.

Implementation

final CollationOptions? collation;