We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running the following code :
try(var client = MongoClients.create(connectString)) { var collection = client.getDatabase("testDatabase").getCollection("testCollection"); var replaceOptions = new ReplaceOptions().upsert(true); System.out.println(collection.bulkWrite( Collections.singletonList(new ReplaceOneModel<>(Filters.eq(new BsonString("myId")), Document.parse("{\"value\": \"test\"}"), replaceOptions)) )); System.out.println(collection.bulkWrite( Collections.singletonList(new ReplaceOneModel<>(Filters.eq(new BsonString("myId")), Document.parse("{}"), replaceOptions)) )); }
Displays the following output :
AcknowledgedBulkWriteResult{insertedCount=0, matchedCount=0, removedCount=0, modifiedCount=0, upserts=[BulkWriteUpsert{index=0, id=BsonString{value='myId'}}], inserts=[]} AcknowledgedBulkWriteResult{insertedCount=0, matchedCount=1, removedCount=0, modifiedCount=0, upserts=[], inserts=[]}
The document is matched but not modified.
Running it against a MongoDB server, we get the following output :
AcknowledgedBulkWriteResult{insertedCount=0, matchedCount=0, removedCount=0, modifiedCount=0, upserts=[BulkWriteUpsert{index=0, id=BsonString{value='myId'}}], inserts=[]} AcknowledgedBulkWriteResult{insertedCount=0, matchedCount=1, removedCount=0, modifiedCount=1, upserts=[], inserts=[]}
And the document is modified as expected.
Using mongo-java-server version 1.44.0 and mongodb-driver-sync version 4.11.1
The text was updated successfully, but these errors were encountered:
Fix replace with empty document (#227)
3cbfa03
Fix replace with empty document (#227) (#229)
0b604ed
Fixed via #229
Sorry, something went wrong.
Fix is released in version 1.45.0
1.45.0
No branches or pull requests
Running the following code :
Displays the following output :
The document is matched but not modified.
Running it against a MongoDB server, we get the following output :
And the document is modified as expected.
Using mongo-java-server version 1.44.0 and mongodb-driver-sync version 4.11.1
The text was updated successfully, but these errors were encountered: