From 0a61d18ba0088b378fcfab6498b3a1c42f9c029f Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Thu, 28 Feb 2019 00:40:15 -0700 Subject: sending geo data to front end, displaying it as markers, and taken out schema defs from index into models folder --- web/models/mockpoints.js | 16 ++++++++++++++++ web/models/points.js | 11 +++++++++++ 2 files changed, 27 insertions(+) create mode 100644 web/models/mockpoints.js create mode 100644 web/models/points.js (limited to 'web/models') diff --git a/web/models/mockpoints.js b/web/models/mockpoints.js new file mode 100644 index 0000000..608c0bd --- /dev/null +++ b/web/models/mockpoints.js @@ -0,0 +1,16 @@ +var mongoose = require('mongoose'); + +var Schema = mongoose.Schema; +var dumbJsonSchema = new Schema({ + type: String, + coordinates: Array +}); + +// Mongoose Model definition +var dumbJson = mongoose.model('dumbJstring', dumbJsonSchema, 'dumbpointscollection'); + +exports.get_dumb_points = function(callback) { + dumbJson.find({}).exec(function(err, docs){ + callback(err, docs) + }); +} diff --git a/web/models/points.js b/web/models/points.js new file mode 100644 index 0000000..18ffe2e --- /dev/null +++ b/web/models/points.js @@ -0,0 +1,11 @@ +var mongoose = require('mongoose'); + +// Mongoose Schema definition +var Schema = mongoose.Schema; +var JsonSchema = new Schema({ + type: String, + coordinates: Array +}); + +// Mongoose Model definition +var Json = mongoose.model('Jstring', JsonSchema, 'pointscollection'); -- cgit v1.2.3 From 9eae2a3a228e9fb65970c1e61d9e4f4429def7a1 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Thu, 28 Feb 2019 10:09:03 -0700 Subject: changed index to use pointscollection by default --- web/models/mockpoints.js | 24 ++++++++++++++++++++---- web/models/points.js | 23 ++++++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) (limited to 'web/models') diff --git a/web/models/mockpoints.js b/web/models/mockpoints.js index 608c0bd..ff5e771 100644 --- a/web/models/mockpoints.js +++ b/web/models/mockpoints.js @@ -1,16 +1,32 @@ var mongoose = require('mongoose'); +// Mongoose Schema definition var Schema = mongoose.Schema; var dumbJsonSchema = new Schema({ type: String, - coordinates: Array + coordinates: Array, + ageRange: String, + clothingDescription: String, + isInjured: Boolean, + reasonForHelp: String }); // Mongoose Model definition var dumbJson = mongoose.model('dumbJstring', dumbJsonSchema, 'dumbpointscollection'); -exports.get_dumb_points = function(callback) { - dumbJson.find({}).exec(function(err, docs){ - callback(err, docs) +// this function gets ALL the points from the db +// returns the entire document without modifications +exports.get_points = function(callback) { + dumbJson.find({}).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) { + dumbJson.create(data, function(err, result) { + if (err) callback(err, null); + callback(null, result); }); } diff --git a/web/models/points.js b/web/models/points.js index 18ffe2e..3a07c82 100644 --- a/web/models/points.js +++ b/web/models/points.js @@ -4,8 +4,29 @@ var mongoose = require('mongoose'); var Schema = mongoose.Schema; var JsonSchema = new Schema({ type: String, - coordinates: Array + coordinates: Array, + ageRange: String, + clothingDescription: String, + isInjured: Boolean, + reasonForHelp: String }); // Mongoose Model definition var Json = mongoose.model('Jstring', JsonSchema, 'pointscollection'); + +// this function gets ALL the points from the db +// returns the entire document without modifications +exports.get_points = function(callback) { + Json.find({}).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) { + if (err) callback(err, null); + callback(null, result); + }); +} -- cgit v1.2.3