Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alin Dumitru
committed
Apr 27, 2011
1 parent
3553227
commit 7a3268c
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var mongo = require('../mongodb' ); | ||
var http = require( 'http' ); | ||
|
||
var N = 1000000; | ||
var replyNo = 1; | ||
|
||
var dbName = 'something'; | ||
var collName = 'else'; | ||
|
||
var collection = null; | ||
|
||
var replSet = new mongo.ReplSetServers( [ new mongo.Server( 'localhost', 27017, { auto_reconnect: true } ) ] ); | ||
|
||
var db = new mongo.Db( dbName, replSet ); | ||
|
||
var runHttp = function () { | ||
http.createServer(function (req, res) { | ||
collection.findOne( {"name":"somename"}, function( err, item ) { | ||
var answer = ''; | ||
if ( !item || err) { | ||
answer = 'Not found.'; | ||
} else { | ||
answer = 'Found.'; | ||
} | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end( answer ); | ||
}); | ||
/*res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end('Found.');*/ | ||
}).listen(1080, "127.0.0.1"); | ||
console.log('Server running at http://127.0.0.1:1080/'); | ||
} | ||
|
||
db.open( function ( err, p_db ) { | ||
db.collection( collName, function( err, coll ) { | ||
collection = coll; | ||
runHttp(); | ||
} ); | ||
} ); |