一、安装依赖
yarn add mongodb
二、app.js
const { MongoClient} = require('mongodb');// Connection URLconst url = 'mongodb://121.36.197.5:10010';const client = new MongoClient(url);const dbName = 'movie';async function main() {await client.connect();console.log('Connected successfully to server');const db = client.db(dbName);const collection = db.collection('user');const result = await collection.find({}).toArray();return result;}main().then(res=>{console.log(res)})
nodemon app.js
