Skip to content

index issue during collection.set #61

Open
@engenb

Description

@engenb

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions