I have a web application where i need to implement search functionality on all the data coming from the Mongodb. I need to combine all the collections and implement search on that.
var db= client.db('bloggingapp');
var collections = db.listCollections().toArray(function (err, names){
const coll = Object.keys(mongoose.connection.collections);
//console.log(coll);
for(var i=0;i<coll.length;i++){
//console.log(coll);
const allData = db.collection(coll[i]).find({}).toArray(function (err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
return result;
});
}
})
I have the complete collection of data in the result json but how do i store it to object so that i can implement my search on that json.