diff options
| author | Kumar Damani <kumar.damani@mail.utoronto.ca> | 2019-03-28 00:59:22 +0000 |
|---|---|---|
| committer | Kumar Damani <kumar.damani@mail.utoronto.ca> | 2019-03-28 01:15:57 +0000 |
| commit | bc966b5e2a4502bf8ad8c7eea9f52ae79f75db87 (patch) | |
| tree | 03da9f18fe70400f1aa93a177a2e260c48f2b2d9 /web/models | |
| parent | 4fa6bdbf7f89ff788b231caef84575daabc0ef9f (diff) | |
saving status of point in db. loading only new or pending points in home page
Diffstat (limited to 'web/models')
| -rw-r--r-- | web/models/points.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/web/models/points.js b/web/models/points.js index 7bb4e24..e8c181e 100644 --- a/web/models/points.js +++ b/web/models/points.js @@ -26,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) { @@ -33,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); + } + ); +} |
