Skip to content

Instantly share code, notes, and snippets.

@koskimas
Created November 17, 2019 09:09
Show Gist options
  • Select an option

  • Save koskimas/17d9efad5de5f474e34ec1cf9722c4b0 to your computer and use it in GitHub Desktop.

Select an option

Save koskimas/17d9efad5de5f474e34ec1cf9722c4b0 to your computer and use it in GitHub Desktop.
class Person extends Model {
static async beforeDelete({
asFindQuery,
cancelQuery
}: StaticHookArguments<Person>): Promise<any> {
const idsOfPersonsAboutToBeDeleted = await asFindQuery().select('id')
if (!(await shouldDelete(idsOfPersonsAboutToBeDeleted))) {
cancelQuery()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment