Skip to content

Instantly share code, notes, and snippets.

@aheckmann
Created October 15, 2011 00:00
Show Gist options
  • Save aheckmann/1288718 to your computer and use it in GitHub Desktop.
Save aheckmann/1288718 to your computer and use it in GitHub Desktop.
// 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