Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Backbone.Model/Collection classes with relation functionality #2

Open
fbuchinger opened this issue Mar 21, 2011 · 1 comment

Comments

@fbuchinger
Copy link

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.

@juggy
Copy link
Owner

juggy commented Mar 21, 2011

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants