There are two collections: Collection A consists of:
-> {"_id": .... , "data":"demon"}
-> {"_id": .... , "data":"god"}
and Collection B consists of:
-> {"_id": .... , "title": "Book A", "description": "this book is about a demon."}
-> {"_id": .... , "title": "Book B", "description": "this book is about a god from Greek."}
-> {"_id": .... , "title": "Book C", "description": "this book is about a dog."}
The task at hand is to retrieve documents from Collection B where the description does not contain any text present in the "data" field of Collection A.
To achieve this in Mongo Query using Plain JS:
collectionA.filter( x => { return !collectionB.some(y => x.description.includes(y.data)});
So the question remains, how can this be accomplished in MongoDB?