Skip to content

Instantly share code, notes, and snippets.

@justinbmeyer
Last active April 18, 2022 20:37
Show Gist options
  • Save justinbmeyer/46ed3ba43437ff825131c23997340a70 to your computer and use it in GitHub Desktop.
Save justinbmeyer/46ed3ba43437ff825131c23997340a70 to your computer and use it in GitHub Desktop.
async $beforeInsert (queryContext) {
await super.$beforeInsert(queryContext)
validateStartDate(this)
const trx = await Person.startTransaction();
await this.validateAssignmentOverlap(this, trx)
queryContext.resolveTransaction = trx;
}
async $afterInsert (queryContext) {
await super.$afterInsert(queryContext)
queryContext.resolveTransaction.commit();
}
// MAKE SURE TO HANDLE ROLLBACK!~!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment