-
Notifications
You must be signed in to change notification settings - Fork 96
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
Blowing up Mongoose with undefined value in $push #167
Comments
So it should be either fixed in Mongoose or can be verified with a simple hook like this: app.service('myservice').before({
update(hook) {
const push = hook.data.$push;
if(push) {
Object.keys(push).forEach(key => {
if(push[key] === undefined) {
throw new Error('You can not push undefined');
}
});
}
}
}); |
trying to wrap my mind around the rationale to make a distinction between Feathers query syntax and the ODM/ORM query syntax in the context of a Feathers wrapper around the ODM/ORM. I've always had wrappers jump thru hoops to make sure the thing being wrapped doesn't blow up with bad input even if it's the responsibility of the thing being wrapped to check for valid input. In other words, trying to gain some wisdom. EDIT: Maybe just enforcing a strict separation of responsibility? setting the expectation for Mongoose to fix its own issues? not covering things up? that sort of thing? |
Anything we add to cover anything up and make it behave differently than the ORM itself is
The bottom line is that Feathers database adapters are just really thin wrappers that provide a common querying syntax. The issue you are describing is definitely a Mongoose bug and Feathers even provides the ability to fairly easily work around it with the hook I posted. |
I think you're also very correct about this from an abstract point of view. The 'before' hooks is a far better place for the fix than in the adapter. Great. Thanks. Will report to Mongoose. I'm working on reproducing another bug I found with Mongoose. |
@daffl 's own code (from prematurely closed issue) with undefined in place of string for value
My question was: should Feathers Mongoose check for existence of value being pushed onto array by $push or is this something that Mongoose must fix?
Output:
The text was updated successfully, but these errors were encountered: