Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = require('express').createServer()
- var mongodb = require("mongodb");
- var sys = require('sys');
- var mongo = new mongodb.MongoDB();
- app.get('/', function(req, res){
- mongo.connect({
- hostname: '127.0.0.1',
- port: 27017,
- db: 'mylittledb'
- });
- mongo.addListener("connection", function () {
- var widgets = mongo.getCollection('widgets');
- widgets.find({ foo:1 }, null, function (results) {
- foo = results[0].foo
- res.send('retrieved data... foo: ' + foo);
- });
- });
- })
- app.listen(3000);
Add Comment
Please, Sign In to add comment