-
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
Add feathers-hooks compatibility. #22
Conversation
This lets you define hooks directly in the entity object: ```js var mongoose = require('mongoose'); var hooks = require('../hooks'); var Property = { schema: { title: {type: String, required: true}, description: {type: String}, sold: {type: Boolean, 'default': false} }, methods: { isComplete: function(){ return this.complete; } }, statics: { }, virtuals: { 'id': function(){ return this._id.toHexString(); } }, indexes: [ ], before:{ find: [hooks.log] } }; module.exports = Property; ```
@ekryski I've run the tests locally and they pass when running a local mongod. I updated the test to show that adding before and after keys to the object does not interfere with the existing tests, but I'm not firing up a server to test the hooks. What do you think? Can we merge? |
@marshallswain Sorry for the delay mate. This kind of slipped passed me in my email. Thanks for pinging again! My first thought was this makes things a bit more inconsistent with the other database adapters, but I think in this case that's ok. The mongoose adapter is a bit special. It works fine on my end so . Could you add some documentation to the readme about how to use them? I think you can just drop in your example. To avoid confusion I think we should also highlight the difference between mongoose middleware and our hooks. A quick stab might be: Feathers hooks are just middleware that are applied at the service level and give you more fine grained control over when each hook is applied by allowing you to specify which CRUD method will trigger them, as opposed to just being called on all saves or updates. With that said, both can be used in conjunction. |
Add feathers-hooks compatibility.
I've added you on NPM. Does this also address #25? If not we might want to add that as well before publishing. Side note: This plugin probably needs to be updated to the new structure, too. |
This doesn't fully address #25. Thanks. |
This lets you define hooks directly in the entity object: