Class 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.

    • Constructor Detail

      • AddFields

        protected AddFields()
    • Method Detail

      • of

        public static AddFields of()
        Creates a new AddFields stage to bind field
        the new stage
      • field

        public AddFields field​(String name,
                               Expression value)
        Add a field to the stage
        name - the name of the new field
        value - the value expression
      • getDocument

        public DocumentExpression getDocument()
        the fields
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.