noveogroup / backbone.iobind

Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.
https://noveogroup.github.io/backbone.iobind/
582 stars 65 forks source link

Can't get it to work with _id #59

Closed Industrial closed 10 years ago

Industrial commented 10 years ago

Hi.

I can't get iosync/iobind to play nicely with MongoDB powered backends. I have set the idAttribute: '_id' on the collection and gave it an URL and did a .fetch().

app.vios.collection.models[0].get('_id')
// => 12345
app.vios.collection.get(app.vios.collection.models[0].get('_id'))
// => undefined

This works fine if I change all _id's to id's on my server side, but that's not a change I am dieing to make since I'm using _id across all of my services.

gr,

Tom

mahnunchik commented 10 years ago

Could you check whether the id attribute is set correctly:

app.vios.collection.at(0).id
Industrial commented 10 years ago

IIRC the .id was not set correctly at that time, but since we've decided that supporting .id instead of _id at our API end points might be a good idea since it allows for easier switching of db layers, so I'm closing the ticket.