I am trying to connect to our internal mongodb cloud DB. I am getting an error cursor.map is not a function. How to solve this problem and I'm not able to find what is causing this error.
const dbConnectionUrl = `mongodb://${user}:${encodeURIComponent(pwd)}@0000000000.dev.cloud.company.net:27017/admin?retryWrites=true&w=majority`;
   const arr = [];
    MongoClient.connect(dbConnectionUrl, {
            useNewUrlParser: true, 
            useUnifiedTopology: true,
        },function(err, client){
            assert.equal(null, err);
            const cursor = client.db('tss-db').collection('jenkins-inventory').find({"instance" : "build01"}).toArray();
            cursor.map(function(instances, err){
                assert.equal(null, err);
                    arr.push(instances);
                    console.log(instances)
                }, 
                function(){
                    client.close()
            res.render('L2');        
        });
    });```
 
    