Package dev.morphia.query
Class Projection
- java.lang.Object
-
- dev.morphia.query.Projection
-
public class Projection extends Object
Defines a query projection
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FindOptions
exclude(String... fields)
Adds a field to the projection clause.FindOptions
include(String... fields)
Adds a field to the projection clause.FindOptions
knownFields()
Configure the project to only return known, mapped fieldsorg.bson.Document
map(Mapper mapper, Class<?> type)
Converts this to Document formFindOptions
project(Meta meta)
Adds a metadata field to a projection.FindOptions
project(String field, ArraySlice slice)
Adds an sliced array field to a projection.String
toString()
-
-
-
Method Detail
-
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:
- Project Fields to Return from Query
-
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:
- Project Fields to Return from Query
-
knownFields
public FindOptions knownFields()
Configure the project to only return known, mapped fields- Returns:
- this
-
map
@Nullable public org.bson.Document map(Mapper mapper, Class<?> type)
Converts this to Document form- Parameters:
mapper
- the Mapper to usetype
- 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 projectslice
- the options for projecting an array field- Returns:
- this
- See Also:
- Project Fields to Return from Query
- 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:
- Project Fields to Return from Query
- MongoDB documentation
- $meta
-
-