I've been testing with this for hours not, but I can't figure out how to make the values I get not be undefined when I return them, as when I console.log it, it works fine but when I return the same object it says Promise { undefined }
Here's the code:-
    function db(fetch) {
    var MongoClient = require('mongodb').MongoClient;
    var url = require('./config.json').mongoURL;
    MongoClient.connect(url, function (err, db) {
        if (err) throw err;
        db.db("test").collection("jsons").findOne({
            ID: fetch
        }, function (err, result) {
            if (err) throw err;
            return result.data; // this is not returning data, even tho console.logging this works.
        });
    });
}
db('aiChannels')
