Skip to content

Fix for deleting an item from non-unique index #24

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

Closed
wants to merge 3 commits into from

Conversation

M1Les
Copy link
Contributor

@M1Les M1Les commented Aug 2, 2021

When an item is removed from the store, non-unique index it is part of, will be reset to undefined:
image

ind.remove will remove all values from the index, even if there are multiple items in that index (in case of non-unique index).

In this fix we're splitting remove operation in two steps for non-unique indices:

  • Find the index value (array of items with the same index)
  • Using primary key, locate and remove the item from the array

There are possibly some performance implications to doing array.filter to remove the item, but could not come up with a better way of removing item without iterating over all array items -- yes, we can stop comparing pks after the first match, but we still need to go over the rest of items to finish copying the array.

@M1Les M1Les closed this Aug 5, 2021
@M1Les
Copy link
Contributor Author

M1Les commented Aug 5, 2021

Closing it in favor of #25

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

Successfully merging this pull request may close these issues.

1 participant