Skip to content

Instantly share code, notes, and snippets.

@danieldanciu
Last active September 14, 2022 06:50
Show Gist options
  • Save danieldanciu/fe6729767a681b6818710911b69153e0 to your computer and use it in GitHub Desktop.
Save danieldanciu/fe6729767a681b6818710911b69153e0 to your computer and use it in GitHub Desktop.
How the callback is registered
logging.info(f'Watching Firestore collection {firestore_prefix}users/<user_id>/jobs '
f'for documents with status=={statuses_of_interest}')
sync_client = firestore.Client(credentials=creds, project=project_id)
# a Firebase index on collection_id and field status MUST exist for this query to work
watched_jobs = sync_client.collection_group(job_collection_id).where('status', 'in', statuses_of_interest)
...
watched_jobs.on_snapshot(callback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment