Skip to content

Commit

Permalink
mongodb config setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Schmidt committed May 23, 2014
1 parent 88c14c0 commit 45482b4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ build/Release
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules


db
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mongourl" : "mongodb://localhost:27017/odl-thek"
}
10 changes: 10 additions & 0 deletions helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var config = require('./config.json');

var db = require('mongoskin').db(config.mongourl);


helper = {
db : db
}

module.exports = helper;
Binary file added routes/.DS_Store
Binary file not shown.
23 changes: 22 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
var express = require('express');

var helper = require('../helper.js');
var odl = helper.db.collection('odl');
var count = helper.db.collection('count');

var router = express.Router();

/* GET home page. */
router.get('/', function(req, res) {

count.find({}).toArray(function(_err,_result){
console.log(_result);
console.log('a');
if(_result&&_result.length > 0) {
console.log('b');
_result[0].count= _result[0].count+1;
count.save(_result[0],function(_err,_result2){
console.log(_result2);
})
} else {
console.log('c');
count.insert({ count : 0},function(_err,_result3){
console.log(_result3);
});
}
});
res.render('index', { title: 'Express' });
});

Expand Down

0 comments on commit 45482b4

Please sign in to comment.