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

Better typings for updating / querying nested objects

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Unknown
    • Resolution: Duplicate
    • 4.8.0
    • None
    • TypeScript
    • Not Needed

    Description

      What problem are you facing?

      Currently, querying / updating deeply nested fields works perfectly, as long as those fields aren't objects themselves.

       

      When they are objects:

      • Querying ignores type validation
      • Updating errors

      What driver and relevant dependency versions are you using?

       

      4.8.0

      Steps to reproduce?

       

      Create a type:

      type User = {
        pet: {
          name: {
            first: string;
            last: string;
          }
        }
      }
       
      // This works when it shouldn't
      const query: mongodb.Filter<User> = { "pet.name": { first: 1 } };
       
      // This doesn't work when it should
      const update: mongodb.UpdateFilter<User> = { "pet.name": { first: "a", last: "b" } }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              eliott@huggingface.co Eliott Coyac
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: