pegli / alloy-ti_touchdb Goto Github PK
View Code? Open in Web Editor NEWAlloy persistence adapter for TiTouchDB
Alloy persistence adapter for TiTouchDB
The model objects should be able to add, read, and remove document attachments. One approach would be to add methods to do this to the Model prototype in afterModelCreate().
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.