Permalink
Browse files

add a longlive example for test #57

  • Loading branch information...
guileen committed Aug 4, 2012
1 parent c8acb90 commit c379ba2c9ca974c92c9dd46c452b1087d3e4e40e
Showing with 28 additions and 0 deletions.
  1. +28 −0 integration/longlive.js
View
@@ -0,0 +1,28 @@
+var mongo = require('../');
+var db = mongo.db('192.168.0.103/test');
+// var db = mongo.db('127.0.0.1/test');
+var myconsole = require('myconsole');
+
+var foo = db.collection('foo');
+
+setInterval(function() {
+ foo.insert({foo:'foo'}, function(err, result){
+ if(err) return myconsole.error(err);
+ foo.count(function(err, count){
+ if(err) return myconsole.error(err);
+ myconsole.log('count: %d', count);
+ foo.find().limit(10).toArray(function(err, arr) {
+ if(err) return myconsole.error(err);
+ myconsole.log('arr: %d', arr.length);
+ })
+ })
+ })
+}, 500);
+
+process.on('SIGINT', function(){
+ myconsole.log('SIGINT')
+ foo.drop(function(err){
+ if(err) myconsole.error(err);
+ process.exit();
+ })
+})

0 comments on commit c379ba2

Please sign in to comment.