diff options
| author | kdam0 <kumar.damani@mail.utoronto.ca> | 2017-01-30 05:02:09 +0000 |
|---|---|---|
| committer | kdam0 <kumar.damani@mail.utoronto.ca> | 2017-01-30 05:02:09 +0000 |
| commit | 98c9cbc6258f699fc944f025230c35faf8575bc2 (patch) | |
| tree | f2c1e809bb2b2573d88ef9bd77eafa65808dca94 /node_simple.js | |
| parent | 541341598d5ed0e5c8ef9b2325dc6bbec958463a (diff) | |
feat. added auto fill for search bar.
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 +} |
