I\'m newbie to MongoDB and Backbone, so I try to understand them, but it is hard. I have a big, big problem: I cannot understand how to manipulate attributes in Backbone.Mod
MongoDB creates _id as an ObjectID, but doesn't retrieve _id as an ObjectID.
Whether this inconsistency is 'correct behaviour' or not, it is certainly an annoying surprise for most MongoDB users.
You can fix it with:
if ( this._id && ( typeof(this._id) === 'string' ) ) {
log('Fixing id')
this._id = mongodb.ObjectID.createFromHexString(this._id)
}
See MongoDB can't update document because _id is string, not ObjectId