String

Last updated last month

String fields store Unicode text, utilizing the native Unicode representation for your version of Python. (On Python 2: unicode, on Python 3: str.)

Import

from marrow.mongo.field import String

Inherits

marrow.mongo:Field

Attributes

This field type inherits all Field attributes and represents a singular, scalar Unicode string value. In addition to the basic attributes, String fields can automatically strip extraneous whitespace on assignment or perform case normalization, e.g. automatic execution of str.upper(), str.lower(), or str.title().

strip

Either the boolean literal True or a string representing the argument to str.strip, that is, the characters to strip.

DefaultFalse

Added>=1.1.1

case

Truthy values (or the string literal "u" or "upper") will request uppercase normalization, falsy values (or the literals "l" or "lower") request lowercase normalization, or the literal "title" can be used to request title case.

DefaultNone

Added>=1.1.1

Usage

Instantiate and assign an instance of this class during construction of a new Document subclass. Accessing as a class attribute will return a Queryable allowing string filtering operations, and access as an instance attribute will return a str (or unicode on Python 2) cast value.

See Also