Hurry
Maple
Lad

Ids in Mongoose, JSON, and Backbone

Crossposted from bites.goodeggs.com

Mongoose adds id sugar on top the default _id document attribute. Backbone has similar sugar, but the types don't line up. Pushing bits between the two with a customary JSON document adds a third representation.

If you find yourself typing vegetable.id when you really needed new ObjectID(vegetable.toJSON()._id) this fancy chart might help:

Mongooseid_id
documentStringObjectID
lean documentObjectID
document.toJSON()ObjectID
JSON
objectString
Backbone
modelString
model.get()String