Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-272

Implement redesigned options for the Collection methods

      As we discussed the options for the mongo package should be implemented as a type with a method for each option that's available. For instance:

      type CountOptions struct{
          opt options.Option
          err error
      }
      
      func (co CountOptions) Limit(int) CountOptions
      func (co CountOptions) MaxTime(time.Duration) CountOptions
      ...
      

      Each method should return the type.

      Ideally this should be implemented as a stack (see the way context.Context is implemented), this way the same base CountOptions can be attached to the mongo.Opt variable and the Options type can simply use a single copy of each type. There should be an error for each type, and either the option or the error should be set.

      Each Collection method should take a single *Options stack. Upon seeing the first error, it should return that error to the user. The methods should unwind the options into a slice and pass that slice to the commands.

            Assignee:
            roland.fong Roland Fong
            Reporter:
            kris.brandow@mongodb.com Kristofer Brandow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: