Details
-
Improvement
-
Resolution: Duplicate
-
Major - P3
-
None
-
4.0.8
-
None
Description
In a Change Stream pipeline, we would like to refer to updated fields in
embedded documents, e.g. updateDescription: { updatedFields: { "a.b.c": "Foo" } }.
But field path expressions cannot refer to such fields because they contain
dots, and field path expressions lack an escape-character; for example like
"$updateDescription.updatedFields.a..b..c".
A workaround for some scenarios is to use the full-document option to have MongoDB
lookup the document and include it in the result, but this incurs a performance-cost
and may return the document in a different state; both of which make the workaround unsuitable for our use-case.
{
|
"_id": { "_data": /**/ },
|
"operationType": "update",
|
"ns": { "db": "test", "coll": "test" },
|
"documentKey": { "_id": /**/ },
|
"updateDescription": {
|
"updatedFields": { "a.b.c": "Foo" },
|
"removedFields": []
|
}
|
}
|
changeStream = db.test.watch(
|
[
|
{
|
$project: {
|
c: "$updateDescription.updatedFields.a.b.c" |
}
|
}
|
]
|
);
|
Attachments
Issue Links
- duplicates
-
SERVER-21889 Oplog format for $set operations on subdocuments creates format that is not queryable
-
- Backlog
-