Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1266

Make KeyVault.getKey() and .getKeyByAltName() return Documents

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.0
    • Affects Version/s: None
    • Component/s: Field Level Encryption
    • None
    • 3
    • Iteration Grouper, Iteration Herring, Iteration Isopod
    • Needed
    • Hide

      The return type of KeyVault.getKey() and KeyVault.getKeyByAltName() changes:

      Both methods now return a single object instead of a cursor if a matching document was found. If no document was found, an empty object with a hint pointing towards no result having been found is returned.

      In the future, the methods will return null instead of this empty object. Cursor methods remain available for now, but are deprecated.

      Show
      The return type of KeyVault.getKey() and KeyVault.getKeyByAltName() changes: Both methods now return a single object instead of a cursor if a matching document was found. If no document was found, an empty object with a hint pointing towards no result having been found is returned. In the future, the methods will return null instead of this empty object. Cursor methods remain available for now, but are deprecated.

      The driver key management API is closely based on mongosh’s, which in turn is based on the legacy shell’s. One difference that the drivers are introducing is that the .getKey() and .getKeyByAltName() methods return Document | null instead of a cursor, which is a sensible decision given that the result consists of either one or zero results.

      Since this is a) the more sensible API choice and b) it aligns with the drivers, we should align with the driver API here as closely as possible.

      In order to avoid a breaking change, could use a JS Proxy object to wrap the result document to still provide cursor methods when they are being accessed. That would only leave a question on what to do if no result was returned – either return null, which is a breaking change compared to current behavior, or a cursor Proxy for e.g. an empty document, which will be a breaking change if/when we remove the Proxy functionality and instead start returning null.

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: