aboutsummaryrefslogtreecommitdiff
path: root/node_simple.js
diff options
context:
space:
mode:
authorHumairAK <humair88@hotmail.com>2016-07-24 20:45:14 +0000
committerHumairAK <humair88@hotmail.com>2016-07-24 20:45:14 +0000
commita0e04574545c4f2751c01c5919c34f6f99bc21ad (patch)
tree6977a38846b9429ed85482d19bc2014072816e3f /node_simple.js
parentd7b7979ee012dde10feae7d64e53fde2847aaf89 (diff)
parent1db8b59bbf49ac4350034385433ffeca5856af83 (diff)
Merge branch 'master' of https://github.com/HumairAK/solutions_repo
Diffstat (limited to 'node_simple.js')
-rw-r--r--node_simple.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/node_simple.js b/node_simple.js
index 003d4a8..942aa4f 100644
--- a/node_simple.js
+++ b/node_simple.js
@@ -841,9 +841,13 @@ exports.get_all_exams = function (course_code, callback) {
// get the exams table
var exam_collection = db.collection('exams');
+ exam_collection.createIndex( // make the following fields searchable
+ {
+ "course_code":"text"
+ });
// search exams table with given course code
exam_collection.find(
- { course_code: course_code }
+ { $text: { $search: course_code } }
).sort({ year: -1}).toArray( function (err, docs) { // order by year
if (err) throw err;
@@ -1085,10 +1089,13 @@ exports.find_course = function (course_code, callback) {
// fetch the courses table
var courses = db.collection('courses');
-
+ courses.createIndex( // make the following fields searchable
+ {
+ "course_code":"text"
+ });
// look for the courses
courses.find(
- { course_code: course_code }
+ { $text: { $search: course_code } }
).toArray(function (err, docs) {
if (err) throw err;
// if this course doesnt exist.... add it (via add_course call)