aboutsummaryrefslogtreecommitdiff
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
parentd7b7979ee012dde10feae7d64e53fde2847aaf89 (diff)
parent1db8b59bbf49ac4350034385433ffeca5856af83 (diff)
Merge branch 'master' of https://github.com/HumairAK/solutions_repo
-rw-r--r--node_simple.js13
-rw-r--r--testImports.js10
2 files changed, 18 insertions, 5 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)
diff --git a/testImports.js b/testImports.js
index 6e80262..0041b02 100644
--- a/testImports.js
+++ b/testImports.js
@@ -40,14 +40,14 @@ var questions_array = ["this is q1", "this is q2"];
});*/
-dbFile.retrieve_userSolutions_history("some_user name", function (bool, result) {
+/*dbFile.retrieve_userSolutions_history("some_user name", function (bool, result) {
if (bool == false) {
console.log(result);
}
else {
console.log(result);
}
-});
+});*/
/*dbFile.retrieve_userSolutions_count("some_user name", function (bool, result) {
if (!bool) console.log(result);
@@ -145,3 +145,9 @@ dbFile.retrieveFollows("some_user names", function (bool, result) {
/*dbFile.remove_user("some_user name", function (bool, mssg) {
console.log(mssg);
});*/
+
+
+/*
+dbFile.search_exams("cSc240", function (bool, mssg) {
+ console.log(mssg);
+});*/