#### This Page

# `lektor.db.``Expression`

Expressions are used to filter down Query objects. They can be passed to the filter function in particular.

The most basic expression is created by accessing the F object which will return an expression that points to a field. Further manipulation of it can create more expressive expressions. `F.name` literally just means that a field by that name exists and is set to a value.

The query syntax is mostly the same in Python as well as in the Jinja 2 templates, the main difference are and and or.

## Example

    >>> p.children.filter((F.name == 'foo') | (F.name == 'bar')).all()
    [<Page model=u'page' id=u'bar'>, <Page model=u'page' id=u'foo'>]

#### !=

Compares an expression to another by ensuring inequality.

#### <

True if the left side is smaller than the right side.

#### <=

True if the left side is smaller or equal to the right side.

#### ==

Compares an expression to another.

#### >

True if the left side is larger than the right side.

#### >=

True if the left side is larger or equal to the right side.

#### and()

True if both left and right side are true.

#### contains()

Checks if an item contains another one.

#### endswith()

True if a string ends with another string (case insensitive).

#### endswith_cs()

True if a string ends with another string (case sensitive).

#### or()

True if either left and right side are true.

#### startswith()

True if a string starts with another string (case insensitive).

#### startswith_cs()

True if a string starts with another string (case sensitive).

## Comments