A simple Python context manager for easy Google Forestore batched writes.
Project description
firestore-batch
A Python context manager for easy Google Forestore batched writes.
What it does for you
- Creates a new batch on entering.
- Takes care of the 500-operation limit. When the limit is hit, it commits accumulated operations to the database and creates a new batch.
- Commits all operations on exit.
Usage
Install with pip:
pip install firestore-batch
Use in your code:
# Initialize the app
from firebase_admin import initialize_app, firestore
initialize_app()
db = firestore.client()
# Make lots of batched writes
from firestore_batch import Batch
with Batch(db) as batch:
for i in range(1000):
batch.set(doc_ref, {f'property_{i}': f'value_{i}'})
Methods
set()
,update()
,delete()
- as in the originalWriteBatch
class (see the documentation with usage examples and API Reference for theWriteBatch
andDocumentReference
classes).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
firestore_batch-0.0.1.tar.gz
(2.1 kB
view hashes)
Built Distribution
Close
Hashes for firestore_batch-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ba8323a9947147587e9ca07ca97bf610261301c2f0f0aa6e9bada60cd007031 |
|
MD5 | 73ccba9a7eede0af5a1c5f58d4dd4d00 |
|
BLAKE2b-256 | fb404426819cb502847fdea2801fc75e0c3312ec3d0d0ecebde935ba2276cfc4 |