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

$addFields with $meta: "recordId" doesn't add new field

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Query Execution
    • ALL

      We see that the new field, which should equal the recordId, is not added to the output:

      > db.newcoll.insert({a: 1})
      WriteResult({ "nInserted" : 1 })
      > db.newcoll.aggregate([{$addFields: {rid: {$meta: "recordId"}}}])
      { "_id" : ObjectId("65c281f44bb7df438ffb4d1e"), "a" : 1 }
      

      However this works with $project instead:

      db.newcoll.aggregate([{$project:{rid: {$meta: "recordId"}} }])
      { "_id" : ObjectId("65c289a24bb7df438ffb4d2a"), "rid" : NumberLong(6) }
      

      See comments for more info.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            vishnu.kaushik@mongodb.com Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: