model modif, id -> _id
authorymh <ymh.work@gmail.com>
Wed, 29 Aug 2012 16:26:13 +0200
changeset 27 6ec62ab8cb8d
parent 26 2fad193bae98
child 29 95a1e550e5b1
model modif, id -> _id
client/js/models.js
--- a/client/js/models.js	Wed Aug 22 16:50:42 2012 +0200
+++ b/client/js/models.js	Wed Aug 29 16:26:13 2012 +0200
@@ -21,7 +21,7 @@
         constructor: function(options) {
             
             if (typeof options !== "undefined") {
-                options._id = options.id || Models.getUID(this);
+                options._id = options._id || options.id || Models.getUID(this);
                 options.title = options.title || "(untitled " + this.type + ")";
                 options.description = options.description || "";
                 options.uri = options.uri || "";
@@ -57,12 +57,12 @@
         },
         toJSON: function() {
             return {
-                id: this.get("id"),
+                _id: this.get("_id"),
                 title: this.get("title"),
                 uri: this.get("uri"),
                 description: this.get("description"),
                 color: this.get("color"),
-            }
+            };
         },
     });
     
@@ -82,13 +82,13 @@
         },
         toJSON: function() {
             return {
-                id: this.get("id"),
+                _id: this.get("_id"),
                 title: this.get("title"),
                 uri: this.get("uri"),
                 description: this.get("description"),
                 position: this.get("position"),
-                created_by: this.get("created_by").get("id")
-            }
+                created_by: this.get("created_by").get("_id")
+            };
         },
     });
     
@@ -121,14 +121,14 @@
         },
         toJSON: function() {
             return {
-                id: this.get("id"),
+                _id: this.get("_id"),
                 title: this.get("title"),
                 uri: this.get("uri"),
                 description: this.get("description"),
-                from: this.get("from").get("id"),
-                to: this.get("to").get("id"),
-                created_by: this.get("created_by").get("id"),
-            }
+                from: this.get("from").get("_id"),
+                to: this.get("to").get("_id"),
+                created_by: this.get("created_by").get("_id"),
+            };
         },
     });