how use nested id's? #1215

Closed
yurtaev opened this Issue Apr 11, 2012 · 4 comments

Comments

Projects
None yet
3 participants

yurtaev commented Apr 11, 2012

Example: mongodb document have a _id.$oid field

Something like this ?

var Model = Backbone.Model.extend({
    idAttribute: '_id',
    parse: function (data) {
        var id = data[this.idAttribute].$oid;
        data[this.idAttribute] = id;
        return data;
    }
});

model = new Model({
    "_id": {
        "$oid": "4dc7f7b7bd0fb9a86c6c80bd"
    },
    "javadriver": "is silly"
}, {
    parse: true
});

@yurtaev yurtaev added a commit to yurtaev/backbone that referenced this issue Apr 17, 2012

@yurtaev yurtaev added support nested id's for model.idAttribute; #1215 0c1c58b
Collaborator

braddunbar commented Apr 17, 2012

As stated in #1232, nested models/ids are not supported directly by Backbone. This type of functionality should be provided by a plugin or extension.

braddunbar closed this Apr 17, 2012

yurtaev commented Apr 17, 2012

Exactly, Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment