-
Notifications
You must be signed in to change notification settings - Fork 74
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
Hook result data shouldn't have sequelize info #24
Comments
This is the expected result of using an ORM. That data can be really useful in other scenarios, so it's generally better to use Sequelize's methods to convert the model instance to an object. See here for ways of doing this: http://stackoverflow.com/questions/21961818/sequelize-convert-entity-to-plain-object |
It's probably worth noting that you would do this in an after hook. |
Hm, I can see what you're saying. I was just thinking it's inconsistent with the regular service hooks. In some cases you're doing At some point those |
@RickEyre for now we leave that up to you because it's not one size fits all. The Sequelize models that get returned have some model properties that come in handy in certain instances, like @marshallswain said. If we are to pluck them from the model and put them as other attributes on With that said, we have bundled hooks with some of the modules and have proposed in #18 and #19 to have similar behavior to the feathers-mongoose adapter, so that you have a hook that will call |
@RickEyre I just generated a new app and took a closer look. I get what you are saying but my previous statement still stands. I think #18 and #19 should solve the problem quite nicely, if you want your results converted to regular objects right away, as opposed to having sequelize models returned. I'm going to close this as we can track progress in those 2 issues. |
Sounds good! Thanks for pointing me in the direction of those issues. |
@RickEyre if you want to implement the hook yourself in the mean time, it's pretty much exactly the same as this one: https://github.com/feathersjs/feathers-mongoose/blob/master/src/hooks.js. PR's are even better! 😄 |
@ekryski Yeah, I was thinking of taking a crack at it 😄 I'll see if I can find some time in the next few days. Doesn't look that difficult! |
@RickEyre @ekryski would using the sequelize model instance's built in |
Sequelize (unfortunately) wraps results by default in DAO's. You can About to go through my project and do that everywhere, in fact. Not that feathers-sequelize should necessarily be opinionated about it, but there are noted performance benefits for disabling DAO's, particularly with complex queries, or queries that return large data sets. |
@petermikitsh @bedeoverend we have been talking about doing a breaking change to both feathers-sequelize and feathers-mongoose so that services are initialized with |
I support that effort. Note that setting |
When using hooks on sequelize services
hook.result
has a lot of extra properties on it then just the data. This makes modifying the result data confusing.The text was updated successfully, but these errors were encountered: