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

Better typings for updating / querying nested objects

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 4.8.0
    • Component/s: TypeScript
    • Not Needed

      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" } }

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

              Created:
              Updated:
              Resolved: