i have a project where i need to fetch a similar array from my mongoDB database. The array will look something like this:
["hi", "how", "are", "you"]
and in the database an entry will look like this:
{
"trigger": ["hi", "how", "are, "you", "doing"],
"response": "Hi, im fine"
}
and there's another document looking like this:
{
"trigger": ["who", "are", "you"],
"response": "I am a bot"
}
So, is there any way to fetch that document from the db just by similar entries and structure of the array.
CodePudding user response:
collection.find({trigger: {$in: inputArray}}, function(err, items){
console.log(err, items);
});
Hope this helps!