Last active
December 24, 2015 11:09
-
-
Save basicdays/6788585 to your computer and use it in GitHub Desktop.
Sample mongodb usage
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
'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