Situation
I wrote a query:
var results = db.collection('diseases').find({
'ttl.txt': {
$regex: data,
$options: 'i'
}
}).toArray();
Problem
Then I printed results to a console.
if (results.length > 0) {
console.log(results);
}
ToArray method must return array of found documents. But this method returns me this string: Promise { <pending> }.
Question
How can I return array of found documents instead of this string?
PS
toArray: Link to the documentation