Skip to content

Separate query and command types in $db update operations #229

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

Closed
wants to merge 1 commit into from

Conversation

danswann
Copy link
Contributor

@danswann danswann commented Jan 3, 2025

Changes types so that partial structure of the update command is no longer inferred from the structure of the update query.

Fixes #227 and goes a little further to enable type-switching, e.g.:

$db.u({value:"hello"}, {$set:{value:27}});

This does mean you lose out on query-based intellisense while constructing the command, e.g.:
image
so it's not a cost-free change.

@samualtnorman
Copy link
Owner

samualtnorman commented Jan 15, 2025

I have made a change, please can you check out the new @dev version. sorry about your PR but I went with a different approach to solving your issue

@danswann
Copy link
Contributor Author

danswann commented Jan 16, 2025

No luck for me on 0.21.1-7696939, same error as in #227.
image

(The final example where I'm not getting yelled at seems like a different bug where using a $-operator in the query breaks inference in the command).

@danswann
Copy link
Contributor Author

I'm happy to toss the PR if you want to move the convo back to the issue and do it your way.

@samualtnorman
Copy link
Owner

No luck for me on 0.21.1-7696939, same error as in #227. image

(The final example where I'm not getting yelled at seems like a different bug where using a $-operator in the query breaks inference in the command).

I am getting different behaviour with the same code, are you sure you restarted your TS server?

@danswann
Copy link
Contributor Author

I am instead sure that I didn't do that. Your fix LGTM.

@danswann danswann closed this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Boolean fields that appear in both the query and command of a MongoDB update can cause error
2 participants