Class AddFields

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

public class AddFields extends Stage
Adds new fields to documents. $addFields outputs documents that contain all existing fields from the input documents and newly added fields.

The $addFields stage is equivalent to a $project stage that explicitly specifies all existing fields in the input documents and adds the new fields.

  • Method Details

    • addFields

      public static AddFields addFields()
      Creates a new AddFields stage
      Returns:
      the new stage
      Since:
      2.2
      MongoDB documentation
      Aggregration Pipeline Stage: $addFields
      Since server release
      3.4
    • field

      public AddFields field(String name, Object value)
      Add a field to the stage
      Parameters:
      name - the name of the new field
      value - the value expression
      Returns:
      this