v3 adapt v2: fix a few bugs with batchUpdate and tasks

This commit is contained in:
Matteo Pagliazzi
2016-04-10 19:09:53 +02:00
parent c6879aa5df
commit 8ea05c3c46
2 changed files with 25 additions and 11 deletions
+12
View File
@@ -123,6 +123,18 @@ TaskSchema.methods.toJSONV2 = function toJSONV2 () {
return toJSON;
};
TaskSchema.statics.fromJSONV2 = function toJSONV2 (taskObj) {
taskObj._id = taskObj.id;
let v2Tags = taskObj.tags || {};
taskObj.tags = [];
taskObj.tags = _.map(v2Tags, (tag, key) => key)
return taskObj;
};
// END of API v2 methods
export let Task = mongoose.model('Task', TaskSchema);