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

index issue during collection.set #61

Open
engenb opened this issue Apr 20, 2015 · 0 comments
Open

index issue during collection.set #61

engenb opened this issue Apr 20, 2015 · 0 comments
Labels

Comments

@engenb
Copy link

engenb commented Apr 20, 2015

I will admit I'm not 100% sure the source of this issue yet. I'm still trying to pinpoint the source, but there is definitely an issue so I figured I'd get this logged.

Here's an example of my data model:
row.js
module.exports = AmpersandModel.extend({ collections: { columns: Cells } });
cells.js
module.exports = AmpersandCollection.extend({ indexes: ['columnDefinitionId'], model: Cell, });
cell.js
module.exports = AmpersandModel.extend({ props: { id: ['number', false, null], columnDefinitionId: ['number', false, null], value: ['string', false, null], } });

When I call row.save(...) I'm seeing issues with the indexes of my cells collection. The indexes look good before, but not after collection.set(...) is invoked.

  1. at some point, _reset is invoked, and at this point, indexes is no longer what I defined. It is an array (length 500, which seems absurdly large for a collection of ~5-6) that looks something like this:
    image
  2. once set has completed, my collection's _indexes looks like this:
    image

As you can see, the cid and id indexes are rebuilt, but the columnDefinitionId index that I defined in my collection is not.

  1. I've found this happens on save, but not fetch.
  2. _addReference appears to be working properly, and, at the point this is invoked for each new model, the new cells are indexed properly.

Any help or insight here would be appreciated as this is creating a pretty major blocker for my project right now. Thanks!

@bear bear added the question label Apr 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants