Function below print list of books when I call.
function getBooks () {
db.find({ }, function (err, docs) {
var async = require('async');
async.map(docs, function(item, callback) {
callback(null, docs);
}, function(err, docs) {
console.log(docs);
})
});
}
getBooks(); // prints a json array: [{book1},{book2},{book3}]
How the getBooks()
function could return the result instead of printing them?
I mean something like below:
var books = getBooks();
console.log(books);
thanks.