add update course and remove course logo fucntionc

parent 2e7b0f05
......@@ -9,7 +9,10 @@ const dbUtils = require('db-utils');
module.exports = function (Course) {
return {
addCourse : function(owner, name, info, description) {
return dbUtils.dbCreateItem(Course,{ owner: owner, name: name, info: info, description: description});
return dbUtils.dbCreateItem(Course,{ owner: owner, name: name, info: info, description: description});
},
updateCourse : function(courseId, owner, name, info, description) {
return dbUtils.dbFindOneAndUpdate(Course,{_id:courseId}, { owner: owner, name: name, info: info, description: description});
},
getCourseById : function (courseId) {
return dbUtils.dbFindOne(Course, {_id: courseId}, [{ path: 'owner' }]);
......
......@@ -3,6 +3,9 @@ const dbUtils = require('db-utils');
module.exports = function (gfs) {
return {
removeCourseLogo : function(path, courseId) {
return dbUtils.removeFile(gfs, courseId.toString() + '/logo.png' );
},
saveCourseLogo : function(path, courseId) {
return dbUtils.copyFileToGridFS(gfs, path, courseId.toString() + '/logo.png' );
},
......
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