Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow strings for Ids in UpdateQuery for nested documents #10573

Closed
lx-0 opened this issue Aug 12, 2021 · 1 comment
Closed

Allow strings for Ids in UpdateQuery for nested documents #10573

lx-0 opened this issue Aug 12, 2021 · 1 comment
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@lx-0
Copy link

lx-0 commented Aug 12, 2021

Do you want to request a feature or report a bug?
feature

What is the current behavior?
Currently when writing a query for a Schema with object ids (refs) in nested documents, the UpdateQuery expects ObjectIds for these nested properties. For all other top-level object id properties, the UpdateQuery either expects ObjectId or string.

What is the expected behavior?
Also allow strings for object ids on nested properties. Therefore make type alias _AllowStringsForIds in index.d.ts recursive:

  type _AllowStringsForIds<T> = {
    [K in keyof T]: [Extract<T[K], mongodb.ObjectId>] extends [never]
      ? T[K] extends object
        ? _AllowStringsForIds<T[K]>
        : T[K]
      : T[K] | string;
    };
@IslandRhythms IslandRhythms added the new feature This change adds new functionality, like a new method or class label Aug 12, 2021
@helgetan
Copy link

Stumbled upon this issue a while ago.
Thumbs up for reporting
+1

@vkarpov15 vkarpov15 added typescript Types or Types-test related issue / Pull Request and removed new feature This change adds new functionality, like a new method or class labels Aug 14, 2021
@vkarpov15 vkarpov15 added this to the 5.13.8 milestone Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

4 participants