aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-18 20:41:32 +0000
committerKumar Damani <kumar.damani@mail.utoronto.ca>2019-02-18 20:41:32 +0000
commit5173673196466206f65ee8e207116839e60fb9d3 (patch)
tree368158c3f5bc033969a398f3d891ace67c637f4a /web
parent35818d32e197903bf314fafe6231f948de6149dd (diff)
properly using the atlas mongo connection
Diffstat (limited to 'web')
-rw-r--r--web/routes/index.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/web/routes/index.js b/web/routes/index.js
index 73520b0..d0b3d7c 100644
--- a/web/routes/index.js
+++ b/web/routes/index.js
@@ -8,6 +8,8 @@ var env = process.env.NODE_ENV || 'development';
var uri;
if (env === 'development') {
uri = 'mongodb://localhost:27017/helpthehome'
+ // use for small testing only if really necessary
+ // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome?retryWrites=true'
} else if (env === 'qa') {
uri = process.env.MONGODB_URI
} else if (env === 'production') {
@@ -19,7 +21,7 @@ mongoose.connect(uri, { useNewUrlParser: true }, function (error) {
if (error) {
console.log(error);
} else {
- console.log("Connected to mongo!");
+ console.log(`connected to ${uri}`);
}
});
@@ -27,11 +29,12 @@ mongoose.connect(uri, { useNewUrlParser: true }, function (error) {
var Schema = mongoose.Schema;
var JsonSchema = new Schema({
name: String,
- type: Schema.Types.Mixed
+ type: Schema.Types.Mixed,
+ coordinates: Array
});
// Mongoose Model definition
-var Json = mongoose.model('JString', JsonSchema, 'pointcollection');
+var Json = mongoose.model('Jstring', JsonSchema, 'pointscollection');
/* GET home page. */
router.get('/', function(req, res, next) {
@@ -42,11 +45,13 @@ router.get('/', function(req, res, next) {
/* GET Map page. */
router.get('/map', function(req,res) {
- // we can use the database to fetch some data, for now just hardcode
- Json.find({},{}, function(e,docs){
+ // we can use the database to fetch a point, SELECT coordinates
+ Json.findOne({name: "points"}, 'coordinates', function(e,point){
+ if (e) return e;
+ // send the view lat, and long.
res.render('map', {
- lat : 43.6529,
- lng : -79.3849
+ lat : point.coordinates[1],
+ lng : point.coordinates[0]
});
});
});