Skip to content

Commit 9397817

Browse files
Add note on logical operators (#4141)
* add note on logical operators * Move logical operators note to DynamoDB conditions section header Move the note about chaining conditions with logical operators (&, |, ~) to appear directly under the "DynamoDB conditions" section header, before the Key and Attr class documentation. This placement makes the information more visible and clarifies that the operators apply to both condition classes. * added examples for each logical operator * remove duplicate note --------- Co-authored-by: veradri <veradri@amazon.com>
1 parent f4381e3 commit 9397817

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/source/reference/customizations/dynamodb.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ Custom Boto3 types
5353
DynamoDB conditions
5454
-------------------
5555

56+
.. note::
57+
58+
Both :py:class:`~boto3.dynamodb.conditions.Key` and
59+
:py:class:`~boto3.dynamodb.conditions.Attr` conditions can be chained
60+
together using the logical operators: ``&`` (and), ``|`` (or), and ``~`` (not).
61+
62+
Example::
63+
64+
# Filter for users named 'John' who are over 25
65+
FilterExpression=Attr('name').eq('John') & Attr('age').gt(25)
66+
67+
# Filter using OR
68+
FilterExpression=Attr('status').eq('active') | Attr('role').eq('admin')
69+
70+
# Filter using NOT
71+
FilterExpression=~Attr('deleted').eq(True)
72+
73+
See :ref:`dynamodb_guide` for more detailed usage examples.
74+
5675
.. autoclass:: boto3.dynamodb.conditions.Key
5776
:members:
5877
:undoc-members:
@@ -61,4 +80,4 @@ DynamoDB conditions
6180
.. autoclass:: boto3.dynamodb.conditions.Attr
6281
:members:
6382
:undoc-members:
64-
:inherited-members:
83+
:inherited-members:

0 commit comments

Comments
 (0)