GithubHelp home page GithubHelp logo

Comments (6)

HenrikJoreteg avatar HenrikJoreteg commented on July 22, 2024

I believe setting mainIndex on the collection will fix that issue. But it's also possible we're not using that quite everywhere in the code.

It's also possible that it's not documented. So we need to address both of those. Thanks for filing this.

https://github.com/AmpersandJS/ampersand-collection/blob/master/ampersand-collection.js#L21

from ampersand-collection.

mhuggins avatar mhuggins commented on July 22, 2024

+1 on this issue. I have mainIndex set to a non-id value on my model, and I ended up with duplicates (that were exponentially duplicated) on saving collections because of this bug. I had to add this hack to all my id-less models:

derived: {
  id: {
    fn: function () {
      return this.name;
    }
  }
}

from ampersand-collection.

HenrikJoreteg avatar HenrikJoreteg commented on July 22, 2024

Thanks @mhuggins will investigate.

from ampersand-collection.

HenrikJoreteg avatar HenrikJoreteg commented on July 22, 2024

Turns out this happened if adding models with custom id attributes, but only if adding them as instantiated models. Anyway, fixed and published as to npm as a patch release v1.3.12. Thanks!

from ampersand-collection.

mhuggins avatar mhuggins commented on July 22, 2024

Thanks for the fix! I'm planning to work on upgrading some plugins this week, so I'll give it a shot. 👍

from ampersand-collection.

mhuggins avatar mhuggins commented on July 22, 2024

Out of curiosity from glancing at the code, it looks like there are a number of other places working with id rather than the collection's mainIndex or model's idAttribute. Just wondering if these might pose as an issue as well. Here are a few examples for references:

from ampersand-collection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.