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

Create aggregation pipeline helpers

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Aggregation
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Defining aggregation pipelines using the Go driver can be a bad experience. The bson.D type (which is frequently used to define agg pipelines) does not provide compile-time safety for types used in aggregation pipelines and the syntax becomes difficult to read quickly as aggregation pipelines become more complex.

      Some other drivers, such as Java and .NET, provide helper functions that add a convenience (and sometimes type-safety) layer on top of the aggregation pipeline syntax, significantly improving the developer experience of using aggregation pipelines. Creating helper functions in the Go driver would provide a similar improvement in the experience of using aggregation pipelines in Go.

      Creating a comprehensive set of aggregation pipeline helpers is a very large task, so to help improve the experience for the majority of users faster, we should target creating helpers for the most popular aggregation pipelines. The helpers need to be able to interoperate with existing bson.D pipeline declaration logic so that users have the option to use a mixture of pipeline stages defined with the helpers and with bson.D.

      Definition of done:

      • Create a set of aggregation pipeline helpers that output aggregation pipeline stages.
      • The helper must be able to be combined with other aggregation pipeline stages defined as bson.D or bson.M (i.e. allow incrementally replacing pipeline stages defined with bson.D/bson.M with helper calls without replacing the entire pipeline).
      • Update all documentation to use the aggregation pipeline helpers instead of bson.D/bson.M where possible.

      Open questions:

      • Should we create a new package (e.g. aggregate.Match), a new type (e.g. mongo.Aggregate().Match), or something else?
      • Should the helper output bson.D or another type? It must be possible to mix helper output with other pipeline stages defined using bson.D/bson.M.

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: