diff options
Diffstat (limited to 'web/models')
| -rw-r--r-- | web/models/mockpoints.js | 2 | ||||
| -rw-r--r-- | web/models/points.js | 20 |
2 files changed, 20 insertions, 2 deletions
diff --git a/web/models/mockpoints.js b/web/models/mockpoints.js index 1bff370..51bd422 100644 --- a/web/models/mockpoints.js +++ b/web/models/mockpoints.js @@ -11,7 +11,7 @@ var dumbJsonSchema = new Schema({ longhair: Boolean, longbeard: Boolean, extra: String, - status: {type: String, default: "new"} + status: String }); // Mongoose Model definition diff --git a/web/models/points.js b/web/models/points.js index 28d43b7..e8c181e 100644 --- a/web/models/points.js +++ b/web/models/points.js @@ -11,7 +11,7 @@ var JsonSchema = new Schema({ longhair: Boolean, longbeard: Boolean, extra: String, - status: {type: String, default: "new"} + status: String }); // Mongoose Model definition @@ -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); + } + ); +} |
