EDIT DUPLICATE
I know that the way explained in the other questions works, but I'm asking something different, that is why the method I'm using is not working when it should
Following this question I've tried to delete all documents in my collection by doing this:
String collectionName = "functionalityLogs";
MongoCollection<LogFunctionDocument> collection = MongoUtilities.getCollectionByName(collectionName, LogFunctionDocument.class);
collection.deleteMany({});
The problem is that it gives me error in the method and tells me
Syntax error, type annotations are illegal here
Also in the docs for the current version the method is the same. What is wrong? I know I can use some "alternatives" like specifying an empty document, but I want to know where I'm wrong in using this method.
EDIT
I've also tried this as already said:
MongoCollection collection = myDB.getCollection(collectionName)
collection.deleteMany({});
But not working.
I know I can use BasicDBObject document = new BasicDBObject();
and pass it to deleteMany
by doing collection.deleteMany(document);
in fact is what I'm doing right now and it works, and also the DBCursors is an alternative, I'm just asking why the above method does not work when it should (or maybe it's all wrong and it shouldn't at all, at this point?).