Code Monkey home page Code Monkey logo

alloy-ti_touchdb's People

Contributors

pegli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

alloy-ti_touchdb's Issues

model.id is not being added to a collection._byId hash table

After digging into the problem of why I wasn't able to get a model from a collection using the Backbone.Collection.get() method, I discovered that the reason for this was because models are being added to the collection by pushing them directly into the Backbone.Collection.models array bypassing the Backbone.Collection.add() method which is where Backbone.Collection._byId is maintained. I can fix this by simply using the Backbone.Collection.push() method, but I noticed you had a comment directly above this snippet of code:

// do not use Collection methods!

The exclamation point means this must be serious...

Of course I can work around it by modifying it like so:

// do not use Collection methods!
var len = 0;
if (!opts.add) {
   collection.models = [];
}
var modelToBeAdded = [];
while (row = rows.nextRow()) {
   var m = collection.map_row(collection.model, row);
   if (m) {
      collection._byId[m.id] = m;
      collection.models.push(m);
      ++len;
   }
}

Out of curiosity, why don't we use the Backbone.Collection methods?

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.