From 4fa6bdbf7f89ff788b231caef84575daabc0ef9f Mon Sep 17 00:00:00 2001 From: Samarth Agarwal Date: Tue, 26 Mar 2019 21:59:36 -0400 Subject: Modified schema to include 'status' in mockpoints.js and points.js. --- web/models/mockpoints.js | 3 ++- web/models/points.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'web/models') diff --git a/web/models/mockpoints.js b/web/models/mockpoints.js index ac9ecd4..51bd422 100644 --- a/web/models/mockpoints.js +++ b/web/models/mockpoints.js @@ -10,7 +10,8 @@ var dumbJsonSchema = new Schema({ race: String, longhair: Boolean, longbeard: Boolean, - extra: String + extra: String, + status: String }); // Mongoose Model definition diff --git a/web/models/points.js b/web/models/points.js index d27f2a7..7bb4e24 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 -- cgit v1.2.3 From bc966b5e2a4502bf8ad8c7eea9f52ae79f75db87 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Wed, 27 Mar 2019 20:59:22 -0400 Subject: saving status of point in db. loading only new or pending points in home page --- web/models/points.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'web/models') 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); + } + ); +} -- cgit v1.2.3