Uploaded image for project: 'MongoDB for IntelliJ Plugin'
  1. MongoDB for IntelliJ Plugin
  2. INTELLIJ-164

handle autocompletion for reused MQL expressions in multiple queries

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Developer Tools

      Autocompletion should recommend only fields that are in the intersection of the schemas of the target queries.

      public List<Document> queryMoviesByYear(String year) {
              return client
                  .getDatabase("sample_mflix")
                  .getCollection("movies")
                  .aggregate(List.of(
                      createMatchStage(year),
                      createGroupStage(),
                      createProjectStage(),
                      createSortStage()
                  ))
                  .into(new ArrayList<>());
          }
      
          public List<Document> queryCommentsByYear(String year) {
              return client
                  .getDatabase("sample_mflix")
                  .getCollection("comments")
                  .aggregate(List.of(
                      createMatchStage(year),
                      createGroupStage(),
                      createProjectStage(),
                      createSortStage()
                  ))
                  .into(new ArrayList<>());
          }
      
          private Bson createMatchStage(String year) {
              return Aggregates.match(Filters.eq("year", year));
          }
      
          private Bson createGroupStage() {
              return Aggregates.group("newField",
                  Accumulators.avg("test", "$year"),
                  Accumulators.sum("test2", "$year"),
                  Accumulators.bottom("field", Sorts.ascending("year"), "$year")
              );
          }
      
          private Bson createProjectStage() {
              return Aggregates.project(Projections.fields(Projections.include("year", "plot")));
          }
      
          private Bson createSortStage() {
              return Aggregates.sort(Sorts.orderBy(Sorts.ascending("asd", "qwe")));
          }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.mas@mongodb.com Kevin Mas Ruiz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: