Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40557

Enable querying of dotted updatedFields in Change Stream pipeline

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.0.8
    • None

      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"
                  }
              }
          ]
      );
      

            Assignee:
            eric.sedor@mongodb.com Eric Sedor
            Reporter:
            simony Simon Yarde
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: