[GODRIVER-1441] DeleteOne does not return any useful information when no document exists Created: 16/Dec/19  Updated: 27/Oct/23  Resolved: 04/Feb/20

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Deepak Sah Assignee: Jeffrey Yemin
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS Catalina



 Description   

`DeleteOne` method on the collection returns a value of type `*mongo.DeleteResult` which has one attribute `DeletedCount` whose value can either be 0 or 1. It would have been better if there was some way of indicating error when no document was found to be deleted instead of manually checking the `DeletedCount` attribute.

`DeletedCount` doesn't seem very useful for testing purposes.



 Comments   
Comment by Divjot Arora (Inactive) [ 04/Feb/20 ]

Hi sah.sslpu@gmail.com,

Sorry for the delay in responding. The MongoDB drivers made a decision to not have the DeleteOne function error if no documents are deleted for idempotency reasons. Given that the Go Driver is post-1.0, it is not possible to change this without making breaking changes or creating additional client options that users would likely forget to enable, so we don't think it's a good idea to change this behavior at this time.

 

– Divjot

Generated at Thu Feb 08 08:36:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.