Skip to content

Instantly share code, notes, and snippets.

@eedrummer
Created November 23, 2015 18:14
Show Gist options
  • Save eedrummer/ee2db2cc1d996f69a7fa to your computer and use it in GitHub Desktop.
Save eedrummer/ee2db2cc1d996f69a7fa to your computer and use it in GitHub Desktop.
"use strict";
let async = require("async");
let MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://127.0.0.1:27017/fhir', function(err, db) {
let patientCollection = db.collection('patients');
let cursor = patientCollection.find()
async.waterfall([
callback => {
cursor.toArray(function(err, items) {
callback(err, items);
});
},
(items, callback) => {
console.log("count: " + items.length);
callback(null);
}
], () => db.close());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment