I want to make an openwhisk action that does something really simple: performs a find query in a mongodb and returns the result. However, since I am new in those technologies, I cannot find a solution, cause I am always recieving no results. I have connected openwhisk with the mongodb correctly. Can anyone help with a code example?
My code so far is this:
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);
});
})
}
I am recieving null as a result. Any suggestions?