Type alias CompositeCondition

A filter or condition expression. This type serves as the root of a object structure for specifying a filter/condition expression which is translated to a DynamoDB Conditional expression for use with some of the available operations (in their underlying ConditionExpression or FilterExpression fields.

The syntax is very similar to Mongo's query syntax, but a little bit stricter to help with type evaluation.

A simple condition expression consists of key paths mapped to an operator. For example, to test profile.username = 'test@example.com', you would construct an expression as follows:

{
'profile.username': { $eq: 'test@example.com' },
}

This expression would be translated to DynamoDB's FilterExpression syntax as:

#attr0.username = :value0

(profile is a reserved word in DynamoDB and automatically mapped. #attr0 and :value0 will be written to ExpressionAttributeNames and ExpressionAttributeValues respectively for you).

Multiple key paths in the same object are treated as an AND operation implicitly.

  • NOTE: For a full list of key path operators, see the [[KeyPathsAndClause]] type.

You can also construct AND, OR and NOT expressions for more complex evaluations, e.g.:

{
$or: [
{ $not: { 'location.value': { $lte: 0 } } },
{
$and: [
{ 'location.point.x': { $gt: 10 } },
{ 'location.point.y': { $gt: 1.3 } },
],
}
],
};

This would be written in DynamoDB's FilterExpression syntax as:

(NOT #attr0.#attr1 <= :value0) OR (#attr0.point.x > :value1 AND #attr0.point.y < :value2)

where:

  • #attr0 is mapped to 'location' (reserved word)
  • #attr1 is mapped to 'value' (reserved word)
  • :value0 is mapped to 0 (Expression Attribute Value)
  • :value1 is mapped to 10 (Expression Attribute Value)
  • :value2 is mapped to 1.3 (Expression Attribute Value)

Generated using TypeDoc