[GODRIVER-1419] add Collection.FindAll Created: 28/Nov/19  Updated: 04/Dec/19  Resolved: 04/Dec/19

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

Type: New Feature Priority: Major - P3
Reporter: Pierre Durand Assignee: Jeffrey Yemin
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Would it be possible to add a new method Collection.FindAll().

The goal is to simplify the usage of Find() + All() (we need to check the error)

It would do this:

  • Call Find()
  • Check the error
  • Call All() with the given slice pointer result

The signature: 

func (coll *Collection) Find(ctx context.Context, filter interface{}, results interface{}, opts ...*options.FindOptions) (*Cursor, error)

What do you think about it ?



 Comments   
Comment by Pierre Durand [ 04/Dec/19 ]

OK

Comment by Jeffrey Yemin [ 02/Dec/19 ]

Hi pierrre

We have to look at it in the context of all the other existing methods that return a (*Cursor, error), of which there are many.  To be consistent the driver would have to include an All variant for each of these methods (e.g. AggregateAll, RunCommandCursor, etc).

While it's slightly more verbose, it's feasible for an application to instead create a helper method that can work with any of the driver's methods that return (*Cursor, error) and implements the behavior that you describe.  Given that, we don't plan to implement this feature.

 

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