Expression to determine the subtype of BinData field

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Here is example of a query that a user may use today using $function. They need a way to get subtype using native agg.

      db.aggregate([
        {
          '$documents': [
            {
              a: {
                '$convert': {
                  input: 'hn3uUsMxSE6S0cVkebjmfg==',
                  to: { type: 'binData', subtype: 0 },
                  format: 'base64'
                }
              },
              b: { '$toUUID': '867dee52-c331-484e-92d1-c56479b8e67e' }
            }
          ]
        },
        {
          '$set': {
            a_subtype: {
              '$function': {
                body: 'function(uuid) { return uuid.type; }',
                args: [ '$a' ],
                lang: 'js'
              }
            },
            b_subtype: {
              '$function': {
                body: 'function(uuid) { return uuid.type; }',
                args: [ '$b' ],
                lang: 'js'
              }
            }
          }
        }
      ])
      >>
      [
        {
          a: Binary.createFromBase64('hn3uUsMxSE6S0cVkebjmfg==', 0),
          b: UUID('867dee52-c331-484e-92d1-c56479b8e67e'),
          a_subtype: 0,
          b_subtype: 4
        }
      ]
      

              Assignee:
              Unassigned
              Reporter:
              Katya Kamenieva
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: