Skip to content

[Firestore] WriteBatch doesn't return instance so you cannot chain. #6548

Closed

Description

@crwilcox

The WriteBatch methods don’t return the WriteBatch instances for chaining.

Activity

  1. tseaver commented on Nov 16, 2018

    @tseaver
    Contributor

    We pretty much never do chaining in Python libs.

  2. added
    type: processA process-related concern. May include testing, release, or the like.
    on Nov 19, 2018
  3. tseaver commented on Nov 26, 2018

    @tseaver
    Contributor

    I would suggest that the "Pythonic" way to provide multiple operations would be to make WriteBatch a context manager, invoking commit from within its __exit__. E.g.:

    with client.batch() as batch:
        batch.create(client.document('documents', 'foo'), {...})
        batch.set(client.document('documents, 'bar'), {...}, merge=True)
        batch.delete(client.document('documents, 'baz'))

    I'm surprised that it doesn't already operate this way.

  4. added a commit that references this issue on Dec 17, 2018
    54e87e1
  5. added a commit that references this issue on Nov 24, 2025
    acad4a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the Firestore API.triaged for GAtype: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions