Skip to content

feature: saving hierarchical entities in one transaction - batch mode on steroids #383

@patrickwolf

Description

@patrickwolf

I think batch mode is great as it provides speed, saves roundtrips and is safe as a single transaction.

What would be an awesome extension is being able to save hierarchies of related entities:

batch_data = [
  {"request_type": "create", "entity_type": "Shot", "entity_id": -1, "data": {"code": "LAX_0001", "project": project}},
  {"request_type": "create", "entity_type": "Shot", "entity_id": -2, "data": {"code": "LAX_0002", "project": project}},
  {"request_type": "create", "entity_type": "Version", "data": {"code": "LAX_0001_v001", "entity":{"type":"shot", "id":-1}}},
  {"request_type": "create", "entity_type": "Version", "data": {"code": "LAX_0001_v002", "entity":{"type":"shot", "id":-1}}},
  {"request_type": "create", "entity_type": "Version", "data": {"code": "LAX_0002_v003", "entity":{"type":"shot", "id":-2}}},
]
sg.batch(batch_data)

No new fields are needed just negative ids and the "only" trick would be to save those entities with a negative id first so that the following ones can reference the generated id's.

Thanks for considering it! Maybe one day someone sets up a whole show in one transaction :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions