aboutsummaryrefslogtreecommitdiff
path: root/web/models
diff options
context:
space:
mode:
authorKumar Damani <damani.kumar@gmail.com>2019-03-05 20:49:57 +0000
committerGitHub <noreply@github.com>2019-03-05 20:49:57 +0000
commit97ae21bf83fb04526269442e2fa3954d99d18665 (patch)
tree4ef4ed4b8e9a079b504c7c31e5f5932bbe459f05 /web/models
parentc16d2af861f4ed452b2b43f087290f5c0889c34d (diff)
parenta08006f89b4252c5edd2d88938ba4e68010b1bd3 (diff)
Merge pull request #22 from csc301-winter-2019/feat7-qa-merging
Feat7 qa merging
Diffstat (limited to 'web/models')
-rw-r--r--web/models/mockpoints.js32
-rw-r--r--web/models/points.js32
2 files changed, 64 insertions, 0 deletions
diff --git a/web/models/mockpoints.js b/web/models/mockpoints.js
new file mode 100644
index 0000000..ff5e771
--- /dev/null
+++ b/web/models/mockpoints.js
@@ -0,0 +1,32 @@
+var mongoose = require('mongoose');
+
+// Mongoose Schema definition
+var Schema = mongoose.Schema;
+var dumbJsonSchema = new Schema({
+ type: String,
+ coordinates: Array,
+ ageRange: String,
+ clothingDescription: String,
+ isInjured: Boolean,
+ reasonForHelp: String
+});
+
+// Mongoose Model definition
+var dumbJson = mongoose.model('dumbJstring', dumbJsonSchema, 'dumbpointscollection');
+
+// 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
new file mode 100644
index 0000000..3a07c82
--- /dev/null
+++ b/web/models/points.js
@@ -0,0 +1,32 @@
+var mongoose = require('mongoose');
+
+// Mongoose Schema definition
+var Schema = mongoose.Schema;
+var JsonSchema = new Schema({
+ type: String,
+ 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);
+ });
+}