public class Field extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Field.FieldProjectionExpression
Intermediate builder part for projecting a
MongoExpression to a result field. |
| Constructor and Description |
|---|
Field() |
| Modifier and Type | Method and Description |
|---|---|
Field |
elemMatch(String field,
Criteria elemMatchCriteria) |
boolean |
equals(Object o) |
Field |
exclude(String... fields)
Exclude one or more
fields from being returned by the query operation. |
Field |
exclude(String field)
Exclude a single
field from being returned by the query operation. |
org.bson.Document |
getFieldsObject() |
int |
hashCode() |
Field |
include(String... fields)
Include one or more
fields to be returned by the query operation. |
Field |
include(String field)
Include a single
field to be returned by the query operation. |
Field |
position(String field,
int value)
The array field must appear in the query.
|
Field.FieldProjectionExpression |
project(MongoExpression expression)
Project a given
MongoExpression to a field included in the
result. |
Field |
projectAs(MongoExpression expression,
String field)
Project a given
MongoExpression to a field included in the
result. |
Field |
slice(String field,
int size)
Project a
$slice of the array field using the first size elements. |
Field |
slice(String field,
int offset,
int size)
Project a
$slice of the array field using the first size elements starting at
offset. |
public Field include(String field)
field to be returned by the query operation.field - the document field name to be included.this field projection instance.public Field.FieldProjectionExpression project(MongoExpression expression)
MongoExpression to a field included 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");
expression - must not be null.Field.FieldProjectionExpression. Define the target field name through
as(String).public Field projectAs(MongoExpression expression, String field)
MongoExpression to a field included 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");
expression - must not be null.field - the field name used in the result.Field.FieldProjectionExpression.public Field include(String... fields)
fields to be returned by the query operation.fields - the document field names to be included.this field projection instance.public Field exclude(String field)
field from being returned by the query operation.field - the document field name to be included.this field projection instance.public Field exclude(String... fields)
fields from being returned by the query operation.fields - the document field names to be included.this field projection instance.public Field slice(String field, int size)
$slice of the array field using the first size elements.field - the document field name to project, must be an array field.size - the number of elements to include.this field projection instance.public Field slice(String field, int offset, int size)
$slice of the array field using the first size elements starting at
offset.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.this field projection instance.public Field position(String field, int value)
$ operator can appear in the projection and
only one array field can appear in the query.field - query array field, must not be null or empty.value - this field projection instance.public org.bson.Document getFieldsObject()
Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.