Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch remove #22

Closed
choxi opened this issue May 24, 2017 · 1 comment
Closed

batch remove #22

choxi opened this issue May 24, 2017 · 1 comment

Comments

@choxi
Copy link
Contributor

choxi commented May 24, 2017

In this function, I'm deleting a list as well as its associated cards (since the data is relational):

deleteList(state, action) {
  ...

  cardIndexes.forEach((index) => {
    state = Tesseract.remove(state.cards, index)
  })

  return Tesseract.remove(state.lists, listIndex)
}

Maybe Tesseract.remove could take an array of indices as well as a single index?

Tesseract.remove(state.cards, cardIndexes)

We were also talking about batch updates the other day, this would be a very good use case for them. I expect that I want my removal of the list and it's associated cards to all happen in one transaction as opposed to individual actions:

state = Tesseract.transaction(() => {
    cardIndexes.forEach((index) => {
    state = Tesseract.remove(state.cards, index)
  })

  return Tesseract.remove(state.lists, listIndex)
})

return state
@ept ept mentioned this issue Jun 22, 2017
@ept
Copy link
Member

ept commented Jun 22, 2017

I'm not sure it's worth adding the additional API surface area for this particular case (I think looping over the cards within a changeset block is not really that bad). Moreover, the transaction block won't actually guarantee that you won't end up with a card referencing a nonexistent list, because another user could concurrently add a card to the list without being aware that it is being deleted.

I'll close this issue, and instead open #29 to think in detail about what support for a relational data model on Tesseract should look like.

@ept ept closed this as completed Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants