java.lang.Object
org.springframework.data.mongodb.core.query.Field
Field projection.
- Author:
- Thomas Risberg, Oliver Gierke, Patryk Wasik, Christoph Strobl, Mark Paluch, Owen Q, Kirill Egorov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceIntermediate builder part for projecting aMongoExpressionto a result field. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanExclude a singlefieldfrom being returned by the query operation.Exclude one or morefieldsfrom being returned by the query operation.exclude(Collection<String> fields) Exclude one or morefieldsfrom being returned by the query operation.org.bson.DocumentinthashCode()Include a singlefieldto be returned by the query operation.Include one or morefieldsto be returned by the query operation.include(Collection<String> fields) Include one or morefieldsto be returned by the query operation.The array field must appear in the query.project(MongoExpression expression) Project a givenMongoExpressionto afieldincluded in the result.projectAs(MongoExpression expression, String field) Project a givenMongoExpressionto afieldincluded in the result.Project a$sliceof the arrayfieldusing the firstsizeelements.Project a$sliceof the arrayfieldusing the firstsizeelements starting atoffset.
-
Constructor Details
-
Field
public Field()
-
-
Method Details
-
include
Include a singlefieldto be returned by the query operation.- Parameters:
field- the document field name to be included.- Returns:
thisfield projection instance.
-
project
Project a givenMongoExpressionto afieldincluded in the result.// { 'name' : { '$toUpper' : '$name' } } // native MongoDB expression .project(MongoExpression.expressionFromString("'$toUpper' : '$name'")).as("name"); // Aggregation Framework expression .project(StringOperators.valueOf("name").toUpper()).as("name"); // Aggregation Framework SpEL expression .project(AggregationSpELExpression.expressionOf("toUpper(name)")).as("name");- Parameters:
expression- must not be null.- Returns:
- new instance of
Field.FieldProjectionExpression. Define the target field name throughas(String). - Since:
- 3.2
-
projectAs
Project a givenMongoExpressionto afieldincluded in the result.// { 'name' : { '$toUpper' : '$name' } } // native MongoDB expression .projectAs(MongoExpression.expressionFromString("'$toUpper' : '$name'"), "name"); // Aggregation Framework expression .projectAs(StringOperators.valueOf("name").toUpper(), "name"); // Aggregation Framework SpEL expression .projectAs(AggregationSpELExpression.expressionOf("toUpper(name)"), "name");- Parameters:
expression- must not be null.field- the field name used in the result.- Returns:
- new instance of
Field.FieldProjectionExpression. - Since:
- 3.2
-
include
Include one or morefieldsto be returned by the query operation.- Parameters:
fields- the document field names to be included.- Returns:
thisfield projection instance.- Since:
- 3.1
-
include
Include one or morefieldsto be returned by the query operation.- Parameters:
fields- the document field names to be included.- Returns:
thisfield projection instance.- Since:
- 4.4
-
exclude
Exclude a singlefieldfrom being returned by the query operation.- Parameters:
field- the document field name to be excluded.- Returns:
thisfield projection instance.
-
exclude
Exclude one or morefieldsfrom being returned by the query operation.- Parameters:
fields- the document field names to be excluded.- Returns:
thisfield projection instance.- Since:
- 3.1
-
exclude
Exclude one or morefieldsfrom being returned by the query operation.- Parameters:
fields- the document field names to be excluded.- Returns:
thisfield projection instance.- Since:
- 4.4
-
slice
Project a$sliceof the arrayfieldusing the firstsizeelements.- Parameters:
field- the document field name to project, must be an array field.size- the number of elements to include.- Returns:
thisfield projection instance.
-
slice
Project a$sliceof the arrayfieldusing the firstsizeelements starting atoffset.- Parameters:
field- the document field name to project, must be an array field.offset- the offset to start at.size- the number of elements to include.- Returns:
thisfield projection instance.
-
elemMatch
-
position
The array field must appear in the query. Only one positional$operator can appear in the projection and only one array field can appear in the query.- Parameters:
field- query array field, must not be null or empty.value-- Returns:
thisfield projection instance.
-
getFieldsObject
public org.bson.Document getFieldsObject() -
equals
-
hashCode
public int hashCode()
-