UPDATE: Nodejs driver 3.X.X introduces a bunch of incompatible changes compared to 2.X.X versions. For one, you will need to use projections instead of field selectors. Also, you will need to pass results from functions by calling callback() which will pass the variable to the caller. function GetTenantIDFromName(exp, db){   let rxPtt = new RegExp(exp, 'gi');   let tID = db.collection('Tenant')     .find({ "Name": { $regex: rxPtt }},{"_id":1})     .toArray();     return tID; } // possible way to call this let tID = GetTenantIDFromName(tenant, db); tID.then(function(polluterTenantId){   console.log(polluterTenantId); }); function GetTenantIDFromName2(exp,…Continue Reading “On: some gotchas working with mongoDB”