Class Set


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

    The $set stage is an alias for $addFields.

    Both stages are equivalent to a $project stage that explicitly specifies all existing fields in the input documents and adds the new fields.

    Since:
    2.3
    • Constructor Detail

      • Set

        protected Set()
    • Method Detail

      • set

        public static Set set()
        Creates a new Set stage
        Returns:
        the new stage
      • field

        public Set field​(String name,
                         dev.morphia.aggregation.expressions.impls.Expression value)
        Add a field to the stage
        Parameters:
        name - the name of the new field
        value - the value expression
        Returns:
        this
      • getDocument

        @MorphiaInternal
        public dev.morphia.aggregation.expressions.impls.DocumentExpression getDocument()
        Returns:
        the fields
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.