I want to check if a string includes a blacklisted text that is in a mongodb collection.
I have tried the code below and it is not logging it to console even if it does include the blacklisted text.
const includesit = await blacklistwordtextthingschema.find({id: `${request.params.id}`});
if(JSON.stringify(request.body).includes(includesit.text)){
console.log('INCLUDES!')
}
2
Answers
I managed to get it working by making the blacklisted text into an array and pushing in the array instead of making a new document for every text.