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

Investigate changes in SERVER-30405: add expression to generate a random number

    XMLWordPrintableJSON

Details

    Description

      Description

      Downstream Change Summary

      We added a new expression, {$rand:{}} which generates a random number between 0 and 1 (as a float). It takes no arguments.

      $rand returns a different value every time it is called. If instead you want to pick a single random number to use for the whole query, you can call $rand in a command-level let variable.

      Description of Linked Ticket

      For generating a random number during aggregation or something like SERVER-22225 it would be nice to have a way to generate a (pseudo-)random number, either as an expression or an a system variable.

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

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

      Attachments

        Activity

          People

            dave.cuthbert@mongodb.com Dave Cuthbert (Inactive)
            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, 3 weeks, 6 days ago