adapt v2: getTask, getTasks, clearCompleted, addTask, deleteTask, getUser, getUserAnonymized, scoreTask (challenge part missing)

This commit is contained in:
Matteo Pagliazzi
2016-04-03 19:03:11 +02:00
parent 58c20c2a64
commit cc65bb1ed7
11 changed files with 309 additions and 160 deletions
+13
View File
@@ -108,6 +108,19 @@ TaskSchema.methods.scoreChallengeTask = async function scoreChallengeTask (delta
await chalTask.save();
};
// Methods to adapt the new schema to API v2 responses (mostly tasks inside the user model)
// These will be removed once API v2 is discontinued
// toJSON for API v2
TaskSchema.methods.toJSONV2 = function toJSONV2 () {
let toJSON = this.toJSON();
toJSON.id = toJSON._id;
return toJSON;
};
// END of API v2 methods
export let Task = mongoose.model('Task', TaskSchema);
// habits and dailies shared fields