Class Group

java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.Group

public class Group extends Stage
Groups input documents by the specified _id expression and for each distinct grouping, outputs a document.
  • Method Details

    • group

      public static Group group(Group.GroupId id)
      Creates a group stage with an ID definition
      Parameters:
      id - the group ID
      Returns:
      the new stage
      Since:
      2.2
      MongoDB documentation
      Aggregration Pipeline Stage: $group
    • group

      public static Group group()
      Creates a group stage with no ID definition
      Returns:
      the new stage
      Since:
      2.2
      MongoDB documentation
      Aggregration Pipeline Stage: $group
    • id

      public static Group.GroupId id()
      Creates an unnamed group ID
      Returns:
      the new groupID
    • id

      public static Group.GroupId id(@Nullable Object name)
      Creates a named group ID
      Parameters:
      name - the id name
      Returns:
      the new groupID
    • field

      public Group field(String name)
      Adds a field to the group.
      Parameters:
      name - the field name
      Returns:
      this
      See Also:
    • field

      public Group field(String name, Object expression)
      Adds a named field to the group with an expression giving the value.
      Parameters:
      name - the name of the field
      expression - the expression giving the value
      Returns:
      this