Having trouble creating an OpenWhisk action that executes a find query in MongoDB and returns the results? No worries, as I am having difficulty getting it to work correctly. Even though I've connected OpenWhisk with MongoDB properly, I'm still not receiving any results. Can someone provide a code example to help me out?
Here's what my current code looks like:
function main(){
var MongoClient = require('mongodb').MongoClient
var url = 'mongodb://192.168.1.14:27017/'
MongoClient.connect(url, (err, db) => {
db.db('yelp').collection('Review').find({stars:5}).limit(100).toArray().then((docs) => {
return docs;
db.close();
}).catch((err) => {
console.log(err.stack);
});
})
}
Unfortunately, I'm only getting null as the result. Any suggestions or tips on how to fix this issue would be greatly appreciated!