How to use the before-after-hook.Hook.Singular function in before-after-hook

To help you get started, we’ve selected a few before-after-hook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JasonEtco / action-record / src / model.ts View on Github external
constructor (model: ModelInput) {
    this.name = model.name
    this.schema = model.schema

    // An object of Hook instances
    this.hooks = {
      create: new Hook.Singular(),
      validate: new Hook.Singular(),
      save: new Hook.Singular()
    }

    // A map of hook names to actual setters
    this.hookMap = {
      beforeCreate: this.hooks.create.before,
      afterCreate: this.hooks.create.after,
      beforeValidate: this.hooks.validate.after,
      afterValidate: this.hooks.validate.after,
      beforeSave: this.hooks.save.after,
      afterSave: this.hooks.save.after,
    }

    // Actually register the hooks
    if (model.hooks) {
      for (const key in model.hooks) {
github JasonEtco / action-record / src / model.ts View on Github external
constructor (model: ModelInput) {
    this.name = model.name
    this.schema = model.schema

    // An object of Hook instances
    this.hooks = {
      create: new Hook.Singular(),
      validate: new Hook.Singular(),
      save: new Hook.Singular()
    }

    // A map of hook names to actual setters
    this.hookMap = {
      beforeCreate: this.hooks.create.before,
      afterCreate: this.hooks.create.after,
      beforeValidate: this.hooks.validate.after,
      afterValidate: this.hooks.validate.after,
      beforeSave: this.hooks.save.after,
      afterSave: this.hooks.save.after,
    }

    // Actually register the hooks
    if (model.hooks) {
      for (const key in model.hooks) {
        const hookFn = model.hooks[key as keyof Hooks]
github JasonEtco / action-record / src / model.ts View on Github external
constructor (model: ModelInput) {
    this.name = model.name
    this.schema = model.schema

    // An object of Hook instances
    this.hooks = {
      create: new Hook.Singular(),
      validate: new Hook.Singular(),
      save: new Hook.Singular()
    }

    // A map of hook names to actual setters
    this.hookMap = {
      beforeCreate: this.hooks.create.before,
      afterCreate: this.hooks.create.after,
      beforeValidate: this.hooks.validate.after,
      afterValidate: this.hooks.validate.after,
      beforeSave: this.hooks.save.after,
      afterSave: this.hooks.save.after,
    }

    // Actually register the hooks
    if (model.hooks) {

before-after-hook

asynchronous before/error/after hooks for internal functionality

Apache-2.0
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis