Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5961

Docs example request: Projection with aggregation expressions

    • 2
    • 0
    • Hide

      DRIVERS-2838:
      Summary of necessary driver changes

      • Add code samples to docs
      • Require MongoDB 4.4+ when running the code in a test suite
         
      Show
      DRIVERS-2838: Summary of necessary driver changes Add code samples to docs Require MongoDB 4.4+ when running the code in a test suite  
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      The documentation team would like to add a new example to the Project Fields to Return from Query Results page

      Acceptance Criteria

      • Add following code (translated to node) in the examples section of the codebase
      • Translate the following code sample into Node Driver syntax 
        db.inventory.find(
           { },
           {
              _id: 0,
              item: 1,
              status: {
                 $switch: {
                    branches: [
                       {
                          case: { $eq: [ "$status", "A" ] },
                          then: "Available"
                       },
                       {
                          case: { $eq: [ "$status", "D" ] },
                          then: "Discontinued"
                       },
                    ],
                    default: "No status found"
                 }
              },
              area: {
                 $concat: [
                    { $toString: { $multiply: [ "$size.h", "$size.w" ] } },
                    " ",
                    "$size.uom"
                 ]
              },
              reportNumber: { $literal: 1 }
           }
        ) 
        
      • Add in code comments so that the code looks like this:
        // Start Aggregation Projection Example 1
        
        <example code>
        
        // End Aggregation Projection Example 1 

            Assignee:
            aditi.khare@mongodb.com Aditi Khare
            Reporter:
            dbeng-pm-bot PM Bot
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: