Permalink
Browse files

pushed too early last time, toObj() should work now. I've updated the…

… example app as well
  • Loading branch information...
1 parent 6aca9e1 commit 643318d1665bc695c1a3317e4e5516c989f7aeff Techwraith committed Mar 14, 2012
Showing with 7 additions and 12 deletions.
  1. +2 −7 examples/todo_app_mongo/lib/model_adapters/todo.js
  2. +5 −5 lib/model/index.js
@@ -49,12 +49,7 @@ var Todo = new (function () {
// Mongo doesn't like it when you send functions to it
// so lets make sure we're only using the properties
- cleanTodo = {
- id: todo.id
- , saved: todo.saved
- , title: todo.title
- , status: todo.status
- };
+ cleanTodo = todo.toObj();
// Double check to see if this thing is valid
todo = geddy.model.Todo.create(cleanTodo);
@@ -80,7 +75,7 @@ var Todo = new (function () {
// if we don't already have the to do item, save a new one
else {
todo.saved = true;
- geddy.db.todos.save(todo, function(err, docs){
+ geddy.db.todos.save(cleanTodo, function(err, docs){
return callback(err, docs);
});
}
View
@@ -131,11 +131,11 @@ utils.mixin(model, new (function () {
and values of the model instance
*/
this.toObj = function () {
- var obj
- , props = this.properties;
- obj.id = this.id;
- for (var p in props) {
- obj[props[p]] = this[props[p]];
+ var obj = {}
+ for (var p in this) {
+ if (typeof this[p] != 'function') {
+ obj[p] = this[p];
+ }
}
return obj;
}

0 comments on commit 643318d

Please sign in to comment.