I am using mongo-java-driver-3.12.X version. I want to change the deprecated API
DBCollection.remove(query, WriteConcern.UNACKNOWLEDGED);
to
MongoCollection.deleteMany(query)
- Is there a way to specify WriteConcern?
- What will be the default behaviour if WriteConcern is not specified?
You can easily find this information in the driver documentation.
WriteConcern can be set to multiple level for 3.12 version it goes like this.
MongoClient:
or with a connection string
MongoDatabase
MongoCollection
This is the case you are interested in
Keep in mind that MongoCollection and MongoDatabase are immutable so calling withWriteConcern create a new instance and has no effect on the original instance.
For the default behavior you need to check the documentation because it depends on your mongodb version.