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

fix(NODE-3452): readonly filters not permitted by typings #2927

Merged
merged 6 commits into from Aug 3, 2021

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Aug 2, 2021

Under certain usages typescript will disallow readonly arrays, when overriding the results of a find is a notable usage, look to the tests for a more complete list. Additionally the result of find was resulting the in the schema unioned with filter operators, there's a test to confirm that no longer occurs.

@dariakp dariakp self-assigned this Aug 2, 2021
@dariakp dariakp added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Aug 2, 2021
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, are we addressing the user's find override request?

by the way we should be able to configure the output type since with a filter we can have a different type than the schema type.

or is that addressed with the other projection ticket?

src/utils.ts Outdated Show resolved Hide resolved
test/types/community/collection/insertX.test-d.ts Outdated Show resolved Hide resolved
test/types/community/collection/insertX.test-d.ts Outdated Show resolved Hide resolved
test/types/community/collection/findX.test-d.ts Outdated Show resolved Hide resolved
nbbeeken and others added 3 commits August 2, 2021 16:57
Co-authored-by: Daria Pardue <81593090+dariakp@users.noreply.github.com>
Co-authored-by: Daria Pardue <81593090+dariakp@users.noreply.github.com>
@nbbeeken nbbeeken requested a review from dariakp August 2, 2021 21:00
src/utils.ts Outdated
indexes.push(key + '_' + indexSpec[key]);
fieldHash[key] = indexSpec[key];
indexes.push(key + '_' + (indexSpec as any)[key]);
fieldHash[key] = (indexSpec as any)[key];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Me again, hope I'm not bothering. Can you (in the interim, per the above conversation) fix needing to add the as any bit by iterating over the result of Object.entries instead? The following seems to make the transpiler happy:

    Object.entries(indexSpec).forEach(([key, value]) => {
      indexes.push(key + '_' + value);
      fieldHash[key] = value;
    });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! thanks :)

@dariakp dariakp merged commit ce51e78 into 4.0 Aug 3, 2021
@dariakp dariakp deleted the NODE-3452/readonly-arrays branch August 3, 2021 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
3 participants