Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3956

Add a helper method to the fluid API to create a document from other fluid method

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Builders
    • Labels:
      None

      In Compass we are providing the feature to allow users to generate code from the aggregation pipelines they've configured - including Java code.

      With the change introduced by JAVA-3338, the code now generates invalid code as we were using and(...) to generate a BSON document.

      The code generation takes a BSON document as an input (noted down in valid JavaScript) and transforms it into idiomatic Java using the fluid API. However, the main piece we are lacking from the fluid API now is to create a "flattened" document out of other fluid API calls.

      Example input BSON document:

      {
          x: "1",
          y: 42
      }
      

      Previously generated output:

      and( eq("x", "1"), eq("y", 42) )
      

      Which now leads to the (wrong) BSON:

      {
         $and: [{ x: "1" }, { y: 42 }]
      }
      

      We would love to have a fluid method like doc(...) or flatten(...) that would allow to generate the following Java code:

      flatten( eq("x", "1"), eq("y", 42) )
      

      And produces the above mentioned input BSON document as result. The semantics regarding overlapping field properties would be that a later flattened document overrides a previous property.

      See COMPASS-4475 and https://mongodb.slack.com/archives/C0V5KNS3X/p1611234779003900 for more context.

            Assignee:
            Unassigned Unassigned
            Reporter:
            michael.rose@mongodb.com Michael Rose (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: