i am getting an error which is saying that n is not defiend at line 47 and i have used all the method to solve it but i am unable to solve it. it is showing and error which is n is undefiend i want to why it is giving me an error and what is the real mistake i am doing to solve it
const MongoClient = require('mongodb').MongoClient;
const assert = require('assert');
// Connection URL
const url = 'mongodb://localhost:27017';
// Database Name
const dbName = 'fruitDB';
// Create a new MongoClient
const client = new MongoClient(url);
// Use connect method to connect to the Server
client.connect(function (err) {
assert.equal(null, err);
console.log("Connected successfully to server");
const db = client.db(dbName);
insertDocuments(db, function() {
client.close();
});
});
const insertDocuments = function(db, callback) {
// Get the documents collection
const collection = db.collection('fruits');
// Insert some documents
collection.insertMany([
{
name: "apple",
score:5,
review: "very very nice"
},
{
name: "orange",
score: 7,
review: "very very sour"
},
{
name: "Banana",
score: 5,
review: "best fruit"
}
], function(err, result) {
assert.equal(err, null);
assert.equal(3, result.result.n);
assert.equal(3, result.ops.length);
console.log("Inserted 3 documents into the collection");
callback(result);
});
}
please solve it