[#1741] remove _id from TaskSchema (we're too deep in our legacy task.id

requirement, we can revisit later)
This commit is contained in:
Tyler Renelle
2013-11-03 21:16:58 -08:00
parent d589c24371
commit 7060f75c83
5 changed files with 17 additions and 28 deletions

View File

@@ -201,6 +201,13 @@ var UserSchema = new Schema({
minimize: false // So empty objects are returned
});
UserSchema.methods.deleteTask = function(tid) {
//user[t.type+'s'].id(t.id).remove();
var task = this.tasks[tid];
var i = this[task.type+'s'].indexOf(task);
if (~i) this[task.type+'s'].splice(i,1);
}
UserSchema.methods.toJSON = function() {
var doc = this.toObject();
doc.id = doc._id;
@@ -209,12 +216,6 @@ UserSchema.methods.toJSON = function() {
doc.filters = {};
doc._tmp = this._tmp; // be sure to send down drop notifs
_.each(['habits','dailys','todos','rewards'], function(type){
_.each(doc[type],function(task){
task.id = task.id || task._id;
})
})
return doc;
};