diff options
Diffstat (limited to 'node_simple.js')
| -rw-r--r-- | node_simple.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/node_simple.js b/node_simple.js index 2f49360..e991515 100644 --- a/node_simple.js +++ b/node_simple.js @@ -117,6 +117,7 @@ var uri = exports.uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/ exports.setupDB = function (callback) { mongoFactory.getConnection(uri).then(function (database) { db = database; + // var corses = exports.find_all_course_codes_from_exams(); callback(true, "Database connected"); // signal start of app }).catch(function (err) { @@ -648,6 +649,28 @@ exports.updatePassword = function (email, password, callback) { /************************* COURSES / EXAMS **********************************/ + +/** + * Find all UNIQUE course codes from EXAMS collection + * + * @param {function} callback: 2 args: (<string>), + * where <string> : couseCodes array + */ +exports.find_all_course_codes_from_exams = function (callback) { + var exams = db.collection('exams'); + exams.distinct("course_code", function (err, result) { + if (err) throw console.log(err); + else { + // console.log(result); + callback(result); + } + }); + + // callback(unique_coursecodes.distinct('course_code')); + // return (unique_coursecodes.distinct('course_code')); +}; + + /** * Remvove a course from ONLY the courses table IN CASE of accidental * addition. @@ -1435,4 +1458,4 @@ exports.getNotifications = function(email, callback) { }); -}
\ No newline at end of file +} |
