Skip to content

Commit

Permalink
samples: Update the read_time snippet. (#363)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
jlara310 and parthea committed Oct 3, 2022
1 parent 4e3e81f commit 0ef55ac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions samples/snippets/snippets.py
Expand Up @@ -58,18 +58,18 @@ def not_in_query(client):


def query_with_readtime(client):
# [START datastore_snapshot_read]
# Create a read time of 120 seconds in the past
read_time = datetime.now(timezone.utc) - timedelta(seconds=120)
# [START datastore_stale_read]
# Create a read time of 15 seconds in the past
read_time = datetime.now(timezone.utc) - timedelta(seconds=15)

# Fetch an entity at time read_time
# Fetch an entity with read_time
task_key = client.key('Task', 'sampletask')
entity = client.get(task_key, read_time=read_time)

# Query Task entities at time read_time
# Query Task entities with read_time
query = client.query(kind="Task")
tasks = query.fetch(read_time=read_time, limit=10)
# [END datastore_snapshot_read]
# [END datastore_stale_read]

results = list(tasks)
results.append(entity)
Expand Down

0 comments on commit 0ef55ac

Please sign in to comment.