By searching on internet I figured out that this is the way to check if a document already exists.
function addSpam(spam){
MongoClient.connect(uri, function(err, db) {
if (err) throw err;
const dbo = db.db("database0");
const query = {link: spam};
const document = dbo.collection("spams").find(query).limit(1);
console.log(document);
db.close();
});
}
Now my issue is that a cursor is returned (as you can see in the output log), I would like to have a bool returned, thanks in advance. (whether the document was found or not)