Skip to content

Commit c5111a4

Browse files
betamooharleyk
authored andcommitted
Update README.rst to include filter conditions (pynamodb#438)
* Update README.rst
1 parent d100b65 commit c5111a4

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

README.rst

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,39 @@ PynamoDB allows you to create the table if needed (it must exist before you can
9595
9696
UserModel.create_table(read_capacity_units=1, write_capacity_units=1)
9797
98-
Now, search your table for all users with a last name of 'Smith' and whose
99-
first name begins with 'J':
98+
Create a new user:
99+
100+
.. code-block:: python
101+
102+
user = UserModel("John", "Denver")
103+
user.email = "[email protected]"
104+
user.save()
105+
106+
Now, search your table for all users with a last name of 'John' and whose
107+
first name begins with 'D':
100108

101109
.. code-block:: python
102110
103-
for user in UserModel.query("Smith", first_name__begins_with="J"):
111+
for user in UserModel.query("John", first_name__begins_with="D"):
104112
print(user.first_name)
105113
106-
Create a new user:
114+
Examples of ways to query your table with filter conditions:
107115

108116
.. code-block:: python
109117
110-
user = UserModel("John", "Denver")
111-
user.save()
118+
for user in UserModel.query("John", filter_condition= (UserModel.email=="[email protected]")):
119+
print(user.first_name)
120+
121+
.. code-block:: python
122+
123+
for user in UserModel.query("John", UserModel.email=="[email protected]"):
124+
print(user.first_name)
125+
126+
.. code-block:: python
127+
128+
# Deprecated, use UserModel.email=="[email protected]" instead
129+
for user in UserModel.query("John", email__eq="[email protected]"):
130+
print(user.first_name)
112131
113132
Retrieve an existing user:
114133

0 commit comments

Comments
 (0)