diff options
| author | ivanshen <iwshen11@gmail.com> | 2019-03-05 04:12:16 +0000 |
|---|---|---|
| committer | ivanshen <iwshen11@gmail.com> | 2019-03-05 04:12:16 +0000 |
| commit | 786d0aacd27f27875568c7a89d9e1df918fadbf3 (patch) | |
| tree | e313a040f1a44d8a3f7cfb51736f295b94d76df6 /web/models/points.js | |
| parent | c16d2af861f4ed452b2b43f087290f5c0889c34d (diff) | |
| parent | 18cfcf14ea982d3277d819b88b0dd4df96da40d0 (diff) | |
Merge branch 'qa' of github.com:csc301-winter-2019/project-team-02 into qa
Diffstat (limited to 'web/models/points.js')
| -rw-r--r-- | web/models/points.js | 32 |
1 files changed, 32 insertions, 0 deletions
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); + }); +} |
