Skip to content

Managing ordering of children? #19

@markerikson

Description

@markerikson

Scenario: Class Parent hasMany Child. I've got a Parent instance with its list of children, as parsed from my backend data. The ordering of those children is important, but is not based on any inherent property (names are arbitrary, child IDs are effectively GUIDs). That said, my server-side Child model does actually have a "sequenceId" field that I update, although I think the way my server logic and my previous app's client logic worked, that didn't actually matter get used much.

I need to be able to insert a new child before or after a given child, as well as re-order children within the list. At the moment, I'm not seeing any obvious way to use Redux-ORM to do that. I see that QuerySet has an orderedBy() function, but that appears to be more for doing ordering within that QuerySet. I also see that a many-relationed QuerySet is given an add() function, but that appears to pretty much just add to the "end" of the list.

Is there any straightforward way to manage ordering of children? One hypothetical workaround might involve "deleting" all children, followed by "re-adding" them in the right order, but that seems awfully complicated.

Any suggestions appreciated.

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