Skip to content

Commit

Permalink
Fix models example code. Closes #1058
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettheel committed Jul 17, 2022
1 parent 555aa3e commit 72a2218
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions examples/model.py
Expand Up @@ -143,7 +143,7 @@ class Meta:
print("Query using aliased attribute: {0}".format(aliased_item))

# Query with filters
for item in Thread.query('forum-1', (Thread.views == 0) | (Thread.replies == 0)):
for item in Thread.query('forum-1', filter_condition=(Thread.views == 0) | (Thread.replies == 0)):
print("Query result: {0}".format(item))


Expand Down Expand Up @@ -184,12 +184,6 @@ class Meta:
Thread.last_post_datetime.set(datetime.now()),
]))

# DynamoDB will delete the item, only if the views attribute is equal to one
try:
print(thread_item.delete(Thread.views == 1))
except:
pass

# Remove an item's attribute
print(thread_item.update(actions=[
Thread.tags.remove()
Expand All @@ -202,8 +196,14 @@ class Meta:
)
]))

# DynamoDB will delete the item, only if the views attribute is equal to one
try:
print(thread_item.delete(Thread.views == 1))
except:
pass

# Backup/restore example
# Print the size of the table
# Print the size of the table (note that this is async/eventually consistent)
print("Table size: {}".format(Thread.describe_table().get('ItemCount')))

# Optionally Delete all table items
Expand Down

0 comments on commit 72a2218

Please sign in to comment.