Class Projections


  • @Deprecated(since="2021-05-27")
    public final class Projections
    extends java.lang.Object
    Deprecated.
    Usage of this API is not supported in AEM as a Cloud Service.
    A factory for projections. A convenient way to use this class is to statically import all of its methods, which allows usage like:
         collection.find().projection(fields(include("x", "y"), excludeId()))
      
    Since:
    3.0
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static <TExpression>
      Bson
      computed​(java.lang.String fieldName, TExpression expression)
      Deprecated.
      Creates a projection of a field whose value is computed from the given expression.
      static Bson elemMatch​(java.lang.String fieldName)
      Deprecated.
      Creates a projection that includes for the given field only the first element of an array that matches the query filter.
      static Bson elemMatch​(java.lang.String fieldName, Bson filter)
      Deprecated.
      Creates a projection that includes for the given field only the first element of the array value of that field that matches the given query filter.
      static Bson exclude​(java.lang.String... fieldNames)
      Deprecated.
      Creates a projection that excludes all of the given fields.
      static Bson exclude​(java.util.List<java.lang.String> fieldNames)
      Deprecated.
      Creates a projection that excludes all of the given fields.
      static Bson excludeId()
      Deprecated.
      Creates a projection that excludes the _id field.
      static Bson fields​(java.util.List<? extends Bson> projections)
      Deprecated.
      Creates a projection that combines the list of projections into a single one.
      static Bson fields​(Bson... projections)
      Deprecated.
      Creates a projection that combines the list of projections into a single one.
      static Bson include​(java.lang.String... fieldNames)
      Deprecated.
      Creates a projection that includes all of the given fields.
      static Bson include​(java.util.List<java.lang.String> fieldNames)
      Deprecated.
      Creates a projection that includes all of the given fields.
      static Bson metaTextScore​(java.lang.String fieldName)
      Deprecated.
      Creates a projection to the given field name of the textScore, for use with text queries.
      static Bson slice​(java.lang.String fieldName, int limit)
      Deprecated.
      Creates a projection to the given field name of a slice of the array value of that field.
      static Bson slice​(java.lang.String fieldName, int skip, int limit)
      Deprecated.
      Creates a projection to the given field name of a slice of the array value of that field.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • computed

        public static <TExpression> Bson computed​(java.lang.String fieldName,
                                                  TExpression expression)
        Deprecated.
        Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported using the $project aggregation pipeline stage.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the projection
        See Also:
        Aggregates.project(Bson)
      • include

        public static Bson include​(java.lang.String... fieldNames)
        Deprecated.
        Creates a projection that includes all of the given fields.
        Parameters:
        fieldNames - the field names
        Returns:
        the projection
      • include

        public static Bson include​(java.util.List<java.lang.String> fieldNames)
        Deprecated.
        Creates a projection that includes all of the given fields.
        Parameters:
        fieldNames - the field names
        Returns:
        the projection
      • exclude

        public static Bson exclude​(java.lang.String... fieldNames)
        Deprecated.
        Creates a projection that excludes all of the given fields.
        Parameters:
        fieldNames - the field names
        Returns:
        the projection
      • exclude

        public static Bson exclude​(java.util.List<java.lang.String> fieldNames)
        Deprecated.
        Creates a projection that excludes all of the given fields.
        Parameters:
        fieldNames - the field names
        Returns:
        the projection
      • excludeId

        public static Bson excludeId()
        Deprecated.
        Creates a projection that excludes the _id field. This suppresses the automatic inclusion of _id that is the default, even when other fields are explicitly included.
        Returns:
        the projection
      • elemMatch

        public static Bson elemMatch​(java.lang.String fieldName)
        Deprecated.
        Creates a projection that includes for the given field only the first element of an array that matches the query filter. This is referred to as the positional $ operator.
        Parameters:
        fieldName - the field name whose value is the array
        Returns:
        the projection
      • elemMatch

        public static Bson elemMatch​(java.lang.String fieldName,
                                     Bson filter)
        Deprecated.
        Creates a projection that includes for the given field only the first element of the array value of that field that matches the given query filter.
        Parameters:
        fieldName - the field name
        filter - the filter to apply
        Returns:
        the projection
      • metaTextScore

        public static Bson metaTextScore​(java.lang.String fieldName)
        Deprecated.
        Creates a projection to the given field name of the textScore, for use with text queries.
        Parameters:
        fieldName - the field name
        Returns:
        the projection
      • slice

        public static Bson slice​(java.lang.String fieldName,
                                 int limit)
        Deprecated.
        Creates a projection to the given field name of a slice of the array value of that field.
        Parameters:
        fieldName - the field name
        limit - the number of elements to project.
        Returns:
        the projection
      • slice

        public static Bson slice​(java.lang.String fieldName,
                                 int skip,
                                 int limit)
        Deprecated.
        Creates a projection to the given field name of a slice of the array value of that field.
        Parameters:
        fieldName - the field name
        skip - the number of elements to skip before applying the limit
        limit - the number of elements to project
        Returns:
        the projection
      • fields

        public static Bson fields​(Bson... projections)
        Deprecated.
        Creates a projection that combines the list of projections into a single one. If there are duplicate keys, the last one takes precedence.
        Parameters:
        projections - the list of projections to combine
        Returns:
        the combined projection
      • fields

        public static Bson fields​(java.util.List<? extends Bson> projections)
        Deprecated.
        Creates a projection that combines the list of projections into a single one. If there are duplicate keys, the last one takes precedence.
        Parameters:
        projections - the list of projections to combine
        Returns:
        the combined projection