Skip to content

Instantly share code, notes, and snippets.

@aherve
Created March 12, 2016 11:24
Show Gist options
  • Select an option

  • Save aherve/dbf2bb4088219fe4720f to your computer and use it in GitHub Desktop.

Select an option

Save aherve/dbf2bb4088219fe4720f to your computer and use it in GitHub Desktop.
import postCreate from '/wathever/postCreate.js'
//... Your schema definition as usual
// declare the plugin for your model
mySchema.plugin(postCreate)
// anywhere else:
mySchema.addPostCreate(function (user, cb) {
// this will only be executed ad the user creation
console.log('a new user has been created !')
return cb(null)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment