不要怂,就是干,撸起袖子干!

Commit ba9a2f65 by Eike Lurz Committed by Pedro Augusto de Paula Barbosa

fix(types): adds 'hooks' to CreateOptions (#11736)

1 parent 91153938
import { ColumnOptions, Model, ModelCtor } from '../model'; import { ColumnOptions, Model, ModelCtor, Hookable } from '../model';
export abstract class Association<S extends Model = Model, T extends Model = Model> { export abstract class Association<S extends Model = Model, T extends Model = Model> {
public associationType: string; public associationType: string;
...@@ -42,17 +42,7 @@ export interface ForeignKeyOptions extends ColumnOptions { ...@@ -42,17 +42,7 @@ export interface ForeignKeyOptions extends ColumnOptions {
/** /**
* Options provided when associating models * Options provided when associating models
*/ */
export interface AssociationOptions { export interface AssociationOptions extends Hookable {
/**
* Set to true to run before-/afterDestroy hooks when an associated model is deleted because of a cascade.
* For example if `User.hasOne(Profile, {onDelete: 'cascade', hooks:true})`, the before-/afterDestroy hooks
* for profile will be called when a user is deleted. Otherwise the profile will be deleted without invoking
* any hooks.
*
* @default false
*/
hooks?: boolean;
/** /**
* The alias of this model, in singular form. See also the `name` option passed to `sequelize.define`. If * The alias of this model, in singular form. See also the `name` option passed to `sequelize.define`. If
* you create multiple associations between the same tables, you should provide an alias to be able to * you create multiple associations between the same tables, you should provide an alias to be able to
......
export interface ValidationOptions { import { Hookable } from "./model";
export interface ValidationOptions extends Hookable {
/** /**
* An array of strings. All properties that are in this array will not be validated * An array of strings. All properties that are in this array will not be validated
*/ */
...@@ -7,9 +9,4 @@ export interface ValidationOptions { ...@@ -7,9 +9,4 @@ export interface ValidationOptions {
* An array of strings. Only the properties that are in this array will be validated * An array of strings. Only the properties that are in this array will be validated
*/ */
fields?: string[]; fields?: string[];
/**
* Run before and after validate hooks.
* @default true.
*/
hooks?: boolean;
} }
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
WhereAttributeHash, WhereAttributeHash,
WhereOperators, WhereOperators,
ModelCtor, ModelCtor,
Hookable,
} from './model'; } from './model';
import { ModelManager } from './model-manager'; import { ModelManager } from './model-manager';
import * as Op from './operators'; import * as Op from './operators';
...@@ -46,7 +47,7 @@ export interface SyncAlterOptions { ...@@ -46,7 +47,7 @@ export interface SyncAlterOptions {
/** /**
* Sync Options * Sync Options
*/ */
export interface SyncOptions extends Logging { export interface SyncOptions extends Logging, Hookable {
/** /**
* If force is true, each DAO will do DROP TABLE IF EXISTS ..., before it tries to create its own table * If force is true, each DAO will do DROP TABLE IF EXISTS ..., before it tries to create its own table
*/ */
...@@ -74,13 +75,9 @@ export interface SyncOptions extends Logging { ...@@ -74,13 +75,9 @@ export interface SyncOptions extends Logging {
*/ */
searchPath?: string; searchPath?: string;
/**
* If hooks is true then beforeSync, afterSync, beforeBulkSync, afterBulkSync hooks will be called
*/
hooks?: boolean;
} }
export interface DefaultSetOptions {} export interface DefaultSetOptions { }
/** /**
* Connection Pool options * Connection Pool options
...@@ -380,7 +377,7 @@ export interface Options extends Logging { ...@@ -380,7 +377,7 @@ export interface Options extends Logging {
retry?: RetryOptions; retry?: RetryOptions;
} }
export interface QueryOptionsTransactionRequired {} export interface QueryOptionsTransactionRequired { }
/** /**
* This is the main class, the entry point to sequelize. To use it, you just need to * This is the main class, the entry point to sequelize. To use it, you just need to
...@@ -1080,7 +1077,7 @@ export class Sequelize extends Hooks { ...@@ -1080,7 +1077,7 @@ export class Sequelize extends Hooks {
* Returns the database name. * Returns the database name.
*/ */
public getDatabaseName() : string; public getDatabaseName(): string;
/** /**
* Returns an instance of QueryInterface. * Returns an instance of QueryInterface.
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!