From 570156914d540177e35967f36e3e934e0fbec944 Mon Sep 17 00:00:00 2001
From: Irene Ros Backbone.Model
Models can be retrieved by id from collections, and the id is used to generate
model URLs by default.
+ idAttributemodel.idAttribute
+
+ By default a model assumes its unique identifier is stored
+ under the id attribute.
+ In certain situations, for example when using CouchDB where the
+ identifying attribute is called _id, overwriting the property
+ name is necessary.
+ Setting the idAttribute during a model definition will
+ set the model's id to the value of the idAttribute property
+ instead. When referencing the model's id, continue
+ using model.id.
+
+
+var Meal = Backbone.Model.extend({ + idAttribute: "_id" +}); +var cake = new Meal({ _id: 1, name: "Cake" }); +alert("Cake id: " + cake.id); ++ +
cidmodel.cid