diff options
| author | Kumar Damani <damani.kumar@gmail.com> | 2019-03-29 20:04:17 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-29 20:04:17 +0000 |
| commit | 6b91cafd7884e1bc5286f17a5c0e5c045130befb (patch) | |
| tree | 3f1934b87b8dfeaa572441c5cce21c1171c4e458 /web/models/points.js | |
| parent | b059abf10a8c04b90eeb457cea1f5589e607c25e (diff) | |
| parent | 834843e6179c94e25157f50d94c3ed3b41802b0b (diff) | |
Merge pull request #64 from csc301-winter-2019/feat/34
Feat/34
Diffstat (limited to 'web/models/points.js')
| -rw-r--r-- | web/models/points.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/web/models/points.js b/web/models/points.js index d27f2a7..e8c181e 100644 --- a/web/models/points.js +++ b/web/models/points.js @@ -10,7 +10,8 @@ var JsonSchema = new Schema({ race: String, longhair: Boolean, longbeard: Boolean, - extra: String + extra: String, + status: String }); // Mongoose Model definition @@ -25,6 +26,14 @@ exports.get_points = function(callback) { }); } +exports.get_all_active_points = function(callback) { + var activeStatusTypes = ["new", "pending"]; + Json.find({ status: { $in: activeStatusTypes } }).exec(function(err, docs) { + if (err) callback(err, null); + callback(null, docs); + }); +} + // this function stores A user report into the db exports.save_request = function(data, callback) { Json.create(data, function(err, result) { @@ -32,3 +41,13 @@ exports.save_request = function(data, callback) { callback(null, result); }); } + +exports.update_point_status = function(id, newStatus, callback) { + Json.findByIdAndUpdate(id, {status: newStatus}, {new: true}, + function(err, result) { + if (err) callback(err, null); + // result contains the updated point document + callback(null, result); + } + ); +} |
