Comments (6)
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.
+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.
Thanks @mhuggins will investigate.
from ampersand-collection.
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.
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.
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)
- Fix performance issues in collections and subcollections HOT 10
- deIndex is being called wrong HOT 8
- -nothing-to-see-here- HOT 1
- Tracking collection state. HOT 13
- .get(id) can't find object with id 0 HOT 2
- .find(query, [indexName]) to retrieve multiple models HOT 4
- using ES5 `bind` for double argument comparator causes Phantom.js to fail HOT 2
- adding element with id:0 results in duplicates
- Upgrade from 1.4.2 to 1.4.3 causes jasmine tests to fail HOT 3
- Consistent sorting functions HOT 4
- Collection of Collections HOT 3
- index issue during collection.set
- Iterable via for...of HOT 1
- Document `parse` method HOT 1
- Collection does not sort itself when elements change HOT 4
- No good hook for when models are inserted
- No "update" event like in Backbone
- lodash helper do not support second parameter binding HOT 1
- Feature Proposal: "cancel" callback in fetch options? HOT 1
- When null is passed as value, it instantiates an empty model in the collection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ampersand-collection.