$replaceWith class
$replaceWith
aggregation stage
Stage description
Available since MongoDB version 4.2
Replaces the input document with the specified document. The operation
replaces all existing fields in the input document, including the _id
field. With $replaceWith
, you can promote an embedded document to the
top-level. You can also specify a new document as the replacement.
The $replaceWith
is an alias for $replaceRoot.
Examples:
Dart code:
$replaceWith(Field('name')).build()
Equivalent mongoDB aggregation stage:
{r'$replaceWith': r'$name'}
Dart code:
$replaceWith($mergeObjects([
{'_id': Field('_id'), 'first': '', 'last': ''},
Field('name')
])).build()
Equivalent mongoDB aggregation stage:
{ $replaceWith: {
$mergeObjects: [ { _id: "$_id", first: "", last: "" }, "$name" ]
}}
https://docs.mongodb.com/manual/reference/operator/aggregation/replaceWith/
- Inheritance
Constructors
- $replaceWith.new(dynamic replacement)
-
Creates
$replaceWith
aggregation stage
Properties
- content → ExpressionContent
-
no setterinherited
-
entry
↔ MapEntry<
String, ExpressionContent> -
getter/setter pairinherited
- fieldName → String
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → String
-
no setterinherited
- rawContent → dynamic
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stageName → String
-
no setterinherited
Methods
-
build(
) → MongoDocument -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited