am trying to read data from local database at “startup_log” collection with NodeJS,
i running in command Prompt the “nodemone createdb.js”, but nothings happened.
my code is below
const MongoClient = require("mongodb").MongoClient;
const url = 'mongodb://localhost:27017/';
const databasename = "local";// Database name
MongoClient.connect(url).then((client) => {
const connect = client.db(databasename);
// Collection name
const collection = connect.collection("startup_log");
collection.find({}).toArray(function(err, result) {
if (err) throw err;
console.log(result.name);
db.close();
});
}).catch((err) => {
console.log(err.Message);
})
can someone help me