Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
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]
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) {