const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://user:password@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=database'; // Database Name const dbName = 'aaaa'; // Create a new MongoClient const op = { useNewUrlParser: true } const client = new MongoClient(url, op); // Use connect method to connect to the Server (async function () { await client.connect(); const db = client.db(dbName); const res = await db.collection('users').find().toArray(); console.log(res); client.close() })();