Package dev.morphia.aggregation.stages
Class Merge<M>
- java.lang.Object
-
- dev.morphia.aggregation.stages.Stage
-
- dev.morphia.aggregation.stages.Merge<M>
-
- Type Parameters:
M
- the entity type
public class Merge<M> extends Stage
Writes the results of the aggregation pipeline to a specified collection. The $merge operator must be the last stage in the pipeline.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCollection()
String
getDatabase()
List<String>
getOn()
Class<M>
getType()
Map<String,dev.morphia.aggregation.expressions.impls.Expression>
getVariables()
MergeOptions.WhenMatched
getWhenMatched()
List<Stage>
getWhenMatchedPipeline()
MergeOptions.WhenNotMatched
getWhenNotMatched()
static <M> Merge<M>
into(Class<M> type)
Creates a new stage targeting the collection mapped for the given typestatic Merge<?>
into(String collection)
Creates a new stage targeting the collectionstatic Merge<?>
into(String database, String collection)
Creates a new stage targeting the database and collectionMerge<M>
let(String variable, dev.morphia.aggregation.expressions.impls.Expression value)
Specifies a variable accessible for use in the whenMatched pipelineMerge<M>
on(String field, String... fields)
Optional.Merge<M>
whenMatched(MergeOptions.WhenMatched whenMatched)
Optional.Merge<M>
whenMatched(List<Stage> pipeline)
Optional.Merge<M>
whenNotMatched(MergeOptions.WhenNotMatched whenNotMatched)
Optional.-
Methods inherited from class dev.morphia.aggregation.stages.Stage
aggregation, stageName
-
-
-
-
Method Detail
-
into
public static <M> Merge<M> into(Class<M> type)
Creates a new stage targeting the collection mapped for the given type- Type Parameters:
M
- the entity type- Parameters:
type
- the target type- Returns:
- the new stage
-
into
public static Merge<?> into(String collection)
Creates a new stage targeting the collection- Parameters:
collection
- the target collection- Returns:
- the new stage
-
into
public static Merge<?> into(String database, String collection)
Creates a new stage targeting the database and collection- Parameters:
database
- the target databasecollection
- the target collection- Returns:
- the new stage
-
getCollection
@MorphiaInternal public String getCollection()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getDatabase
@Nullable @MorphiaInternal public String getDatabase()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getOn
@MorphiaInternal public List<String> getOn()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getType
@Nullable @MorphiaInternal public Class<M> getType()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getVariables
@MorphiaInternal public Map<String,dev.morphia.aggregation.expressions.impls.Expression> getVariables()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getWhenMatched
@MorphiaInternal public MergeOptions.WhenMatched getWhenMatched()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getWhenMatchedPipeline
@MorphiaInternal public List<Stage> getWhenMatchedPipeline()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getWhenNotMatched
@MorphiaInternal public MergeOptions.WhenNotMatched getWhenNotMatched()
- Returns:
- the value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
let
public Merge<M> let(String variable, dev.morphia.aggregation.expressions.impls.Expression value)
Specifies a variable accessible for use in the whenMatched pipeline- Parameters:
variable
- the variable namevalue
- the value expression- Returns:
- this
-
on
public Merge<M> on(String field, String... fields)
Optional. Field or fields that act as a unique identifier for a document. The identifier determines if a results document matches an already existing document in the output collection.- Parameters:
field
- the first fieldfields
- the other fields- Returns:
- this
-
whenMatched
public Merge<M> whenMatched(MergeOptions.WhenMatched whenMatched)
Optional. The behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s).- Parameters:
whenMatched
- the behavior- Returns:
- this
-
whenMatched
public Merge<M> whenMatched(List<Stage> pipeline)
Optional. An aggregation pipeline to update the document in the collection.- Parameters:
pipeline
- the pipeline- Returns:
- this
-
whenNotMatched
public Merge<M> whenNotMatched(MergeOptions.WhenNotMatched whenNotMatched)
Optional. The behavior of $merge if a result document does not match an existing document in the out collection.- Parameters:
whenNotMatched
- the behavior- Returns:
- this
-
-