-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Go Drivers
Context
It's very common to want to call {{FindOne(bson.D
{"_id", idVal})}}, and fairly common to also to update, replace, or delete one doc based on the ID. In these cases, it'd be nice to have a helper that just took the ID value:
func (coll *Collection) FindOneByID(id any, opts ...*options.FindOneOptions) *SingleResult { return coll.FindOne(bson.D{{"_id", id}}) }
Besides being convenient, it also eliminates the potential for typos, like using "id" instead of "_id".
Definition of done
Add at least the proposed FindOneByID method. I think the others would be used less. OTOH, they're all equally trivial to add.
Pitfalls
I can't think of any.
- related to
-
GODRIVER-2999 Implemente ReplaceByID
- Closed
-
GODRIVER-3012 Create a CRUD query filters helper
- Backlog
-
GODRIVER-3006 Deprecate Collection.UpdateByID
- Blocked