Extend Backbone.Model/Collection classes with relation functionality
Your project sounds interesting and I'm eager to give it a try. One question though: why don't you provide your "orm" functionality by extending Backbone's Model/Collection classes instead of "mixing" in these functions via initialize? I'm thinking of something like:
Pokepic.Model = Backbone.Model.extend({
hasMany: {},
embedsMany:{},
_setupRelations: (){
//all inner relations are setup here
}
});
The user would then simply use your Pokepic.Model / Pokepic.Collection to specify his tasks.
That would be a possibility. At first I didn't want to change backbone directly for this project.
The problem with your solution is when the overridden initialize do not call the super initializer (as it is not done by the language). Also initialize is called by the backbone.model constructor which would require changes to backbone directly.