Created
October 15, 2011 00:00
-
-
Save aheckmann/1288718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pre hook | |
var emailAuthor = function( done ){ | |
console.log( '\nemailing author!\n' ); | |
done(); | |
}; | |
BlogPost.pre( 'save', function( next ){ | |
//next( new Error('something went wrong') ); | |
next(); | |
}); | |
BlogPost.pre( 'save', true, function( next, done ){ | |
// ^^^^ // pass `true` for async middleware | |
next(); | |
emailAuthor( done ); // <-- `done` must come after `next` | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment