mongodb - Aggregate data using mongo-spring aggregation framework -


i in need of retrieving grades in between 40-60. folloiwng code snipit tried.

@document(collection = "grade") public class grade{              private string courseid;         private string assignmentid;         private string studentid;                private studentsubmissions studentsubmissions;     //getters setters omitted } 

follwoing studentsubmissions class

  public class studentsubmissions{         private string id;         private int grade;         private string version;       //getters setters omitted      } 

following aggregate method.

public list<gradesummary> aggregate(float mingrade, float maxgrade) {         criteria pricecriteria = where("grade").gt(mingrade).andoperator(where("grade").lt(maxgrade));          return mongotemplate.aggregate(aggregation.newaggregation(                  match(pricecriteria),                 group("studentsubmissions")                 .sum("grade").as("grades"),                  project()                    .and("studentsubmissions").previousoperation()          ), grade.class, gradesummary.class).getmappedresults();     } 

gradesummary class defines structure in desired output format

public class gradesummary {     private string grade;      private int grades; } 

i need retrieve grades in between given range. , map values gradesummary i'm not sure structure. there error when retrieving data , should wrong group() , project() methods. can me this.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -