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()
})();

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-12-30
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案