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

Types don't allow for overwriting a document with an object of the same type

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.13.0, 4.12.1
    • Component/s: TypeScript
    • None
    • 2
    • Not Needed
    • Not Needed

      What problem are you facing?

      The TS types don't allow you to $set a document with an object of the same type as the collection if that type includes arrays.

      Here's the interface:

      What driver and relevant dependency versions are you using?

      MongoDB v4.13.0, TypeScript v4.9.4, Node v18.12.1

      Steps to reproduce?

      1. Create an interface where one of the properties is an array
      2. Assign that interface to a collection
      3. Try to update a document in that collection by using $set with an object of the same type as the interface
      4. Workaround: try to do the same but instead of doing $set: obj, do $set: { ...obj } (this works for some reason)

       

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

              Created:
              Updated: