Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongodb = require('mongodb');
- console.log('Loading function');
- exports.handler = function(event, context) {
- console.log("Connecting to Mongo");
- mongodb.MongoClient.connect('mongodb://xxxx:xxxx@dsxxxx-a0.mlab.com:xxxx,xxxx-a1.mlab.com:xxxx/xxxxxx?replicaSet=rs-xxxxx', function(err, db) {
- console.log("Connected to mongo");
- var col = db.collection('tasks');
- col.find({ }).toArray(function(err, docs) {
- if (err) {
- console.log('err > ' + err);
- throw err;
- }
- console.log('docs.length > ' + docs.length);
- docs.forEach(function(x) {
- console.log(x._id);
- });
- db.close();
- console.log("Done");
- context.done(null, "finished");
- });
- });
- };
Add Comment
Please, Sign In to add comment