Class Projection

java.lang.Object
dev.morphia.query.Projection

public class Projection extends Object
Defines a query projection
  • Method Details

    • exclude

      public FindOptions exclude(String... fields)
      Adds a field to the projection clause. The _id field is always included unless explicitly suppressed.
      Parameters:
      fields - the fields to exclude
      Returns:
      this
      See Also:
    • include

      public FindOptions include(String... fields)
      Adds a field to the projection clause. The _id field is always included unless explicitly suppressed.
      Parameters:
      fields - the fields to include
      Returns:
      this
      See Also:
    • knownFields

      public FindOptions knownFields()
      Configure the project to only return known, mapped fields
      Returns:
      this
    • map

      @Nullable public Document map(Mapper mapper, Class<?> type)
      Converts this to Document form
      Parameters:
      mapper - the Mapper to use
      type - the entity type
      Returns:
      this
    • project

      public FindOptions project(String field, ArraySlice slice)
      Adds an sliced array field to a projection.
      Parameters:
      field - the field to project
      slice - the options for projecting an array field
      Returns:
      this
      See Also:
      MongoDB documentation
      $slice
    • project

      public FindOptions project(Meta meta)
      Adds a metadata field to a projection.
      Parameters:
      meta - the metadata option for projecting
      Returns:
      this
      See Also:
      MongoDB documentation
      $meta
    • toString

      public String toString()
      Overrides:
      toString in class Object