I just want the function to return the result of a mongodb query, and I can't get it to not return a promise.
function findResult(sequence){
return dbo.collection("counter").findOne({ name: sequence })
}
I've tried so many things like await, callbacks using .then etc. Examples would be really appreciated, can't find any up-to-date examples on how to do this.
Edit:
I'm using the result to auto increment.
function findResult(sequence) {
return dbo.collection("counter")
.findOne({ name: sequence })
.then(function (res) {
return res;
})
.catch(function (err) {
});
}
let result = findResult('test');
console.log(result)
And this still returns
Promise { <pending> }