diff --git a/index.html b/index.html index c9d5f29a4..d25868b8f 100644 --- a/index.html +++ b/index.html @@ -684,7 +684,30 @@
+ 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