hooks-js
hooks-js copied to clipboard
Augment your methods with pre and post hooks
Using callbacks: ```js toySchema.pre('save', function (next) { if (!this.created) this.created = new Date next() }) ``` Using promises: ```js toySchema.pre('save', async function () { if (!this.created) this.created = new Date...
What about using hooks in base and sub classes ? Look at this use case ``` js var hooks = require("hooks") var _ = require('underscore') // Document definition var Document...
With 0.3.2 and 0.2.1 ``` js var hooks = require('hooks'); function Doc(data) { this.name = data.name; } // Add hooks' methods: `hook`, `pre`, and `post` for (var k in hooks)...
As per subject, thanks
For the lawyers
Also tested using `npm test`.
Let's say I have a JavaScript constructor as follows: ``` js function MyModel() { } MyModel.create = function(...); ``` How can I set up pre/post hooks for MyModel.create? The code...
This fix is definitely needed to make mongoosejs work with 0.3.0 and asyncronous post middlewares. It fixes callbacks (adds proper arguments). Thank you
Would it be possible to include a LICENSE file with the text of the license agreement? Our lawyers are saying that just having "License: MIT" is not sufficient.