Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13923

Investigate changes in SERVER-51362: Ensure that update and delete shell helpers support 'let' variables

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • 4.9.0
    • None
    • None
    • None

    Description

      Description

      Downstream Change Summary

      This provides 'let' parameter support in the update and remove shell helpers to mirror the let variable support in the update and delete server commands.

      Description of Linked Ticket

      The update command supports let parameters, but the db.collection.update() shell helper does not.

       

      The following update command works:

      db.runCommand({
          update: db.cakeSales.getName(),
          updates: [
              {q: {$expr: {$eq: [“$salesTotal”, “$$targetTotal”], u: [{$set: {salesTotal: “$$newTotal”}}]}
          ],
          let : {targetTotal: 2150, newTotal: 2155}
      });

       

      But the corresponding command using the shell helper fails with errmsg: “Use of undefined variable: targetTotal”.

      db.cakeSales.update(
         {$expr: {$eq: [“$salesTotal”, “$$targetTotal”],
         {$set: {salesTotal: “$$newTotal”,
         {let : {targetTotal: 4350, newTotal: 4200}}
      );

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

      Attachments

        Activity

          People

            Unassigned Unassigned
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              3 years, 17 weeks, 5 days ago