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

Parse Sets as arrays when adding to a document

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: BSON

      How are you using Mongo? What version of the server and driver are you using?

      I'm using it on my application, server is on version 5.0.8 Community and I'm using version 5.7.0 of the driver

      What is the feature/improvement you would like?

      Currently if you try to create a document with one of its properties being a Set (or update a document to add it, the result is the same) it is parsed as an empty object, which is undesirable. Sets in JS are simply arrays with no duplicated keys so these could instead be parsed as arrays and inserted as such. You can easily turn any variable set into an array by doing [...set] so this should be easy to add.

      What use case would this feature/improvement enable?

      My use case is that I have a bunch of arrays in a document but I have to remove and add elements to them in the same operation, so I first find them and edit them on the app, replacing them later. However these arrays must have unique elements so I use Sets and it would be nice to be able to directly $set these without having to turn them into arrays myself.

            Assignee:
            Unassigned Unassigned
            Reporter:
            rodrigoleitao25@gmail.com Rodrigo Leitão
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: