-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
types: allow arbitrary keys in query filters again #14874
Conversation
Sorry, sounds good to me! Waiting for 9.0 to make it a breaking change seems reasonable. Guess we could even expose a "typesafe" or "unsafe" version of each function to allow people to opt out, although unsafe is the same as just doing |
@alex-statsig there's also another issue that popped up in #14842: Mongoose discriminators support specifying the discriminator key in the query filter, and Mongoose will infer the schema based on the discriminator key. For example: const Person = new Schema({ name: String });
const Employee = Person.discriminator('Employee', new Schema({ title: String }));
// Because discriminator key `__t` is set, Mongoose is able to infer the type of the `title` property, even
// though the model is `Person` not `Employee`
await Person.findOne({ __t: 'Employee', title: 'CEO' }); Is there a way to support this with TypeScript? I imagine we would need some way of defining what discriminators are tied to a particular model in TS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, lets wait for 9.0 to re-consider introducing this strictness
@@ -216,7 +216,7 @@ function find() { | |||
Project.find({ name: 'Hello' }); | |||
|
|||
// just callback; this is no longer supported on .find() | |||
expectError(Project.find((error: CallbackError, result: IProject[]) => console.log(error, result))); | |||
Project.find((error: CallbackError, result: IProject[]) => console.log(error, result)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after the revert, does the "expectError" now fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert #14764
Fix #14863
Fix #14862
Summary
#14764 introduced issues for quite a few devs, see #14863. We should revert for now, and consider adding #14764 in 9.0.
cc @alex-statsig
Examples