add subscribe to course and unsubscribe functions

parent 4b54491f
......@@ -82,6 +82,12 @@ module.exports = function (User) {
},
updateMeta : function (userId, meta) {
return dbUtils.dbFindOneAndUpdate(User, {_id : userId}, {meta : meta});
},
subscribeCourse : function(userId, courseId) {
return dbUtils.dbFindOneAndUpdate(User, {_id : userId}, { $addToSet: {'meta.courses': courseId } });
},
unsubscribeCourse : function(userId, courseId) {
return dbUtils.dbFindOneAndUpdate(User, {_id : userId}, { $pull: {'meta.courses': courseId } });
}
}
};
{
"name": "mirera-db",
"version": "1.4.2",
"version": "1.4.3",
"description": "DB utils for mirera program testing server",
"main": "index.js",
"scripts": {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment