Condition Expression

On This Page

Overview

A condition expression is an expression that defines a condition for executing an operation, based on the attributes of the items against which the expression is evaluated. For example, the NoSQL Web API UpdateItem operation receives an optional condition-expression request parameter (ConditionExpression) that defines a condition that determines whether to update the item or which update expression to use in the case of an if-then-else update.

Filter Expression

For operations that retrieve existing item attributes, the condition expression acts as a filter expression that restricts the operation to a subset of items to be returned in the response. For example, the NoSQL Web API GetItems operation receives an optional FilterExpression request parameter that defines a condition that determines which items to return.

Syntax

"CONDITION [LOGICAL-OPERATOR CONDITION ...]"

A condition expression is a Boolean expression that is composed of one or more Boolean expressions (CONDITION) that are connected using a binary logical operator (LOGICAL-OPERATOR) — AND or OR. The unary logical operator NOT can be used to negate a condition.
A condition can optionally be enclosed within parentheses.

Note
If a condition within the expression references an attribute that is not set in the evaluated item, the condition fails (evaluates to false). The result of the entire condition expression depends on the expression’s overall logic.

Examples

  1. Check for “Car” products with less than 15 known bugs:

    "(bugs < 15) AND starts(Product_Name, 'Car')"
        
  2. Check for 40-year-old people whose first names are “John” and are not residents of Arizona or Massachusetts:

    "(age == 40) and (firstName == 'John') and NOT(State IN ('AZ','MA'))"
        

  3. Check for released adult prisoners who haven’t reported to their parole officer:

    "(age > 18) AND isReleased==true AND reported==false"
        

See Also