# PreHookOptions Decorator

Module
import { PreHookOptions } from "@tsed/mongoose/src/decorators/preHook"
Source/packages/mongoose/src/decorators/preHook.ts

# Overview

interface PreHookOptions {
    parallel?: boolean;
    errorCb?: HookErrorCallback;
}
/**
 *
 * We can simply attach a `@PreHook` decorator to your model class and
 * define the hook function like you normally would in Mongoose.
 *
 * ```typescript
 * import {IgnoreProperty, Required} from "@tsed/common";
 * import {PreHook, Model} from "@tsed/mongoose";
 *
 * @Model()
 * @PreHook("save", (car: CarModel, next) => {
 *    if (car.model === 'Tesla') {
 *        car.isFast = true;
 *      }
 *      next();
 *})
 * export class CarModel {
 *
 *    @IgnoreProperty()
 *    _id: string;
 *
 *    @Required()
 *    model: string;
 *
 *    @Required()
 *    isFast: boolean;
 *
 *    // or Prehook on static method
 *    @PreHook("save")
 *    static preSave(car: CarModel, next) {
 *       if (car.model === 'Tesla') {
 *           car.isFast = true;
 *       }
 *       next();
 *    }
 * }
 * ```
 *
 * This will execute the pre-save hook each time a `CarModel` document is saved.
 *
 * @param {string} method
 * @param fn
 * @param options
 * @returns {Function}
 * @decorator
 * @class
 */