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

Document Extended JSON format for Code and CodeWScope

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • manual, Server

    Description

      Document MongoDB extended JSON syntax for the following BSON types

      • javascript (type 13)
      • javascript with scope (type 15)

      Using the node driver to insert such types (via bson.Code()), then mongoexport-ing the documents, the strict extended json syntax seems to be:

      Javascript

          {
              "$code": "function () { return 1+1; }"
          }
      

      Javascript with Scope:

          {
              "$code": "function () { return a+b; }",
              "$scope": {
                  "a": 1,
                  "b": 2
              }
          }
      

      In the shell, there is a Code() helper function, but I can't find documentation for it.

      Attachments

        Activity

          People

            Unassigned Unassigned
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              1 year, 14 weeks, 2 days ago