Skip to content

Instantly share code, notes, and snippets.

@basicdays
Last active December 24, 2015 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basicdays/6788585 to your computer and use it in GitHub Desktop.
Save basicdays/6788585 to your computer and use it in GitHub Desktop.
Sample mongodb usage
'use strict';
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost/snmp', function(err, db) {
if (err) {error(err);}
db.collection('rawscandata5', function(err, collection) {
if (err) {error(err);}
collection.find().count(function(err, result) {
if (err) {error(err);}
console.log(result);
db.close(function(err) {
if (err) {error(err);}
})
});
})
});
function error(err) {
console.error(err);
process.exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment