hettlage (136) [Avatar] Offline
The database is not passed as an argument to the callback function of MongoDB.connect; the MongoDB client is. So (based on https://github.com/mongodb/node-mongodb-native) the code probably should look something like the following.

const MongoDB = require('mongodb').MongoClient;

MongoDB.connect('mongodb://localhost:27017', (error, client) => {
    if (error) throw error;
    const db = client.db('csa_app_db');
    db.collection('contacts').find().toArray((error, data) => {
        if (error) throw error;

ryanthtra (5) [Avatar] Offline
Thanks! That seems to be the new syntax for v3 of the Node MongoDB driver, which is installed by default by npm if you don't specify the version number.

You can use either the new code you wrote or npm install v2 of the driver:

$ npm install mongodb@2 --save
TheWexler (62) [Avatar] Offline
Thanks you two! These are too good solutions. These changes will be reflected in the next update.