sequelize-typescript
- Version 2.1.6
- Published
- 216 kB
- 1 dependency
- MIT license
Install
npm i sequelize-typescript
yarn add sequelize-typescript
pnpm add sequelize-typescript
Overview
Decorators and some other features for sequelize
Index
Variables
Functions
- addAssociation()
- addAttribute()
- addAttributeOptions()
- addFieldToIndex()
- addHook()
- addOptions()
- addScopeOptions()
- addScopeOptionsGetter()
- AfterBulkCreate()
- AfterBulkDestroy()
- AfterBulkRestore()
- AfterBulkSync()
- AfterBulkUpdate()
- AfterConnect()
- AfterCreate()
- AfterDefine()
- AfterDestroy()
- AfterFind()
- AfterInit()
- AfterRestore()
- AfterSave()
- AfterSync()
- AfterUpdate()
- AfterUpsert()
- AfterValidate()
- AllowNull()
- annotateModelWithIndex()
- AutoIncrement()
- BeforeBulkCreate()
- BeforeBulkDestroy()
- BeforeBulkRestore()
- BeforeBulkSync()
- BeforeBulkUpdate()
- BeforeConnect()
- BeforeCount()
- BeforeCreate()
- BeforeDefine()
- BeforeDestroy()
- BeforeFind()
- BeforeFindAfterExpandIncludeAll()
- BeforeFindAfterOptions()
- BeforeInit()
- BeforeRestore()
- BeforeSave()
- BeforeSync()
- BeforeUpdate()
- BeforeUpsert()
- BeforeValidate()
- BelongsTo()
- BelongsToMany()
- Column()
- Comment()
- Contains()
- CreatedAt()
- createIndexDecorator()
- Default()
- DefaultScope()
- DeletedAt()
- Equals()
- ForeignKey()
- getAssociations()
- getAssociationsByRelation()
- getAttributes()
- getHooks()
- getIndexes()
- getModelName()
- getModels()
- getOptions()
- getPreparedAssociationOptions()
- getScopeOptions()
- getScopeOptionsGetters()
- getSequelizeTypeByDesignType()
- HasMany()
- HasOne()
- implementHookDecorator()
- Index()
- inferDataType()
- installHooks()
- Is()
- IsAfter()
- IsAlpha()
- IsAlphanumeric()
- IsArray()
- IsBefore()
- IsCreditCard()
- isDataType()
- IsDate()
- IsDecimal()
- IsEmail()
- IsFloat()
- IsIn()
- IsInt()
- IsIP()
- IsIPv4()
- IsIPv6()
- IsLowercase()
- IsNull()
- IsNumeric()
- IsUppercase()
- IsUrl()
- IsUUID()
- Length()
- Max()
- Min()
- Not()
- NotContains()
- NotEmpty()
- NotIn()
- NotNull()
- prepareArgs()
- prepareOptions()
- PrimaryKey()
- resolveModelGetter()
- resolveScope()
- resolveScopes()
- resolvesDeprecatedScopes()
- Scopes()
- setAssociations()
- setAttributes()
- setHooks()
- setIndexes()
- setModelName()
- setOptions()
- setScopeOptionsGetters()
- Table()
- Unique()
- UpdatedAt()
- Validate()
- ValidationFailed()
- verbose()
Classes
Interfaces
Enums
Type Aliases
Variables
variable DataType
const DataType: any;
variable INFER_ALIAS_MAP
const INFER_ALIAS_MAP: { bulkBuild: number; build: number; create: number; aggregate: number; all: number; find: number; findAll: number; findAndCount: number; findAndCountAll: number; findById: number; findByPrimary: number; findCreateFind: number; findOne: number; findOrBuild: number; findOrCreate: number; findOrInitialize: number; reload: number;};
Indicates which static methods of Model has to be proxied, to prepare include option to automatically resolve alias; The index represents the index of the options of the corresponding method parameter
variable Validator
const Validator: MethodDecorator;
Functions
function addAssociation
addAssociation: <TCreationAttributes extends {}, TModelAttributes extends {}>( target: any, association: BaseAssociation<TCreationAttributes, TModelAttributes>) => void;
Stores association meta data for specified class
function addAttribute
addAttribute: (target: any, name: string, options: any) => void;
Adds model attribute by specified property name and sequelize attribute options and stores this information through reflect metadata
function addAttributeOptions
addAttributeOptions: ( target: any, propertyName: string, options: ModelAttributeColumnOptions) => void;
Adds attribute options for specific attribute
function addFieldToIndex
addFieldToIndex: ( target: any, fieldOptions: IndexFieldOptions, indexOptions: IndexOptions, indexId?: string | number) => string | number;
Adds field to index by sequelize index and index field options, and stores this information through reflect metadata. Returns index ID.
function addHook
addHook: ( target: any, hookType: keyof SequelizeHooks, methodName: string, options?: HookOptions) => void;
Adds hook meta data for specified model
Throws
if applied to a non-static method
Throws
if the hook method name is reserved
function addOptions
addOptions: (target: any, options: ModelOptions<any>) => void;
Adds options be assigning new options to old one
function addScopeOptions
addScopeOptions: <TCreationAttributes extends {}, TModelAttributes extends {}>( target: any, options: ScopeOptions<TCreationAttributes, TModelAttributes>) => void;
Adds scope option meta data for specified prototype
Deprecated
function addScopeOptionsGetter
addScopeOptionsGetter: (target: any, options: ScopeOptionsGetters) => void;
function AfterBulkCreate
AfterBulkCreate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterBulkDestroy
AfterBulkDestroy: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterBulkRestore
AfterBulkRestore: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterBulkSync
AfterBulkSync: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterBulkUpdate
AfterBulkUpdate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterConnect
AfterConnect: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterCreate
AfterCreate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterDefine
AfterDefine: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterDestroy
AfterDestroy: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterFind
AfterFind: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterInit
AfterInit: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterRestore
AfterRestore: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterSave
AfterSave: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterSync
AfterSync: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterUpdate
AfterUpdate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterUpsert
AfterUpsert: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AfterValidate
AfterValidate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function AllowNull
AllowNull: { (target: any, propertyName: string): void; (allowNull: boolean): Function;};
Sets allowNull true for annotated property column.
function annotateModelWithIndex
annotateModelWithIndex: ( target: any, propertyName: string, optionsOrName?: IndexDecoratorOptions | string, indexId?: string | number) => string | number;
function AutoIncrement
AutoIncrement: (target: any, propertyName: string) => void;
Sets auto increment true for annotated field
function BeforeBulkCreate
BeforeBulkCreate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeBulkDestroy
BeforeBulkDestroy: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeBulkRestore
BeforeBulkRestore: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeBulkSync
BeforeBulkSync: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeBulkUpdate
BeforeBulkUpdate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeConnect
BeforeConnect: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeCount
BeforeCount: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeCreate
BeforeCreate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeDefine
BeforeDefine: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeDestroy
BeforeDestroy: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeFind
BeforeFind: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeFindAfterExpandIncludeAll
BeforeFindAfterExpandIncludeAll: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeFindAfterOptions
BeforeFindAfterOptions: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeInit
BeforeInit: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeRestore
BeforeRestore: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeSave
BeforeSave: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeSync
BeforeSync: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeUpdate
BeforeUpdate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeUpsert
BeforeUpsert: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BeforeValidate
BeforeValidate: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function BelongsTo
BelongsTo: { <TCreationAttributes extends {}, TModelAttributes extends {}>( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, foreignKey?: string ): Function; <TCreationAttributes extends {}, TModelAttributes extends {}>( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options?: BelongsToOptions ): Function;};
function BelongsToMany
BelongsToMany: { < TCreationAttributes extends {}, TModelAttributes extends {}, TCreationAttributesThrough extends {}, TModelAttributesThrough extends {} >( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, through: | ModelClassGetter<TCreationAttributesThrough, TModelAttributesThrough> | string, foreignKey?: string, otherKey?: string ): Function; < TCreationAttributes extends {}, TModelAttributes extends {}, TCreationAttributesThrough extends {}, TModelAttributesThrough extends {} >( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options: BelongsToManyOptions< TCreationAttributesThrough, TModelAttributesThrough > ): Function;};
function Column
Column: { (dataType: DataType): Function; (options: ModelAttributeColumnOptions): Function; ( target: any, propertyName: string, propertyDescriptor?: PropertyDescriptor ): void;};
function Comment
Comment: (value: string) => PropertyDecorator;
Sets the specified comment value for the annotated field
function Contains
Contains: (value: string | { msg: string; args: string }) => Function;
Force specific substrings
function CreatedAt
CreatedAt: (target: any, propertyName: string) => void;
function createIndexDecorator
createIndexDecorator: (options?: IndexOptions) => IndexDecorator;
function Default
Default: (value: any) => Function;
Sets the specified default value for the annotated field
function DefaultScope
DefaultScope: { (scopeGetter: DefaultScopeGetter): Function; <TCreationAttributes extends {}, TModelAttributes extends {}>( scope: ScopeFindOptions<TCreationAttributes, TModelAttributes> ): Function;};
Decorator for defining default Model scope
Decorator for defining default Model scope
Deprecated
function DeletedAt
DeletedAt: (target: any, propertyName: string) => void;
function Equals
Equals: (value: string | { msg: string; args: string }) => Function;
Only allow a specific value
function ForeignKey
ForeignKey: <TCreationAttributes extends {}, TModelAttributes extends {}>( relatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>) => Function;
function getAssociations
getAssociations: <TCreationAttributes extends {}, TModelAttributes extends {}>( target: any) => BaseAssociation<TCreationAttributes, TModelAttributes>[] | undefined;
Returns association meta data from specified class
function getAssociationsByRelation
getAssociationsByRelation: < TCreationAttributes extends {}, TModelAttributes extends {}>( target: any, relatedClass: any) => BaseAssociation<TCreationAttributes, TModelAttributes>[];
function getAttributes
getAttributes: (target: any) => any | undefined;
Returns model attributes from class by restoring this information from reflect metadata
function getHooks
getHooks: (target: any) => HookMeta[] | undefined;
Returns hooks meta data from specified class
function getIndexes
getIndexes: (target: any) => IndexesMeta;
Returns model indexes from class by restoring this information from reflect metadata
function getModelName
getModelName: (target: any) => string;
Returns model name from class by restoring this information from reflect metadata
function getModels
getModels: (arg: (ModelCtor | string)[], modelMatch: ModelMatch) => ModelCtor[];
Determines models from value
function getOptions
getOptions: (target: any) => ModelOptions | undefined;
Returns sequelize define options from class prototype by restoring this information from reflect metadata
function getPreparedAssociationOptions
getPreparedAssociationOptions: ( optionsOrForeignKey?: string | NonBelongsToManyAssociationOptions) => NonBelongsToManyAssociationOptions;
function getScopeOptions
getScopeOptions: <TCreationAttributes extends {}, TModelAttributes extends {}>( target: any) => ScopeOptions<TCreationAttributes, TModelAttributes> | undefined;
Returns scope option meta data from specified target
Deprecated
function getScopeOptionsGetters
getScopeOptionsGetters: (target: any) => ScopeOptionsGetters;
function getSequelizeTypeByDesignType
getSequelizeTypeByDesignType: ( target: any, propertyName: string) => DataTypeAbstract;
Maps design types to sequelize data types;
Throws
if design type cannot be automatically mapped to a sequelize data type
function HasMany
HasMany: { <TCreationAttributes extends {}, TModelAttributes extends {}>( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, foreignKey?: string ): Function; <TCreationAttributes extends {}, TModelAttributes extends {}>( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options?: HasManyOptions ): Function;};
function HasOne
HasOne: { <TCreationAttributes extends {}, TModelAttributes extends {}>( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, foreignKey?: string ): Function; <TCreationAttributes extends {}, TModelAttributes extends {}>( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options?: HasOneOptions ): Function;};
function implementHookDecorator
implementHookDecorator: ( hookType: keyof SequelizeHooks, args: any[]) => Function | void;
Implementation for hook decorator functions. These are polymorphic. When called with a single argument (IHookOptions) they return a decorator factory function. When called with multiple arguments, they add the hook to the model’s metadata.
function Index
Index: { (name: string): Function; (options: IndexDecoratorOptions): Function; ( target: any, propertyName: string, propertyDescriptor?: PropertyDescriptor ): void;};
function inferDataType
inferDataType: (designType: any) => DataTypeAbstract | undefined;
Infers sequelize data type by design type
function installHooks
installHooks: (models: ModelCtor[]) => void;
Installs hooks on the specified models
function Is
Is: { (name: string, validator: (value: any) => any): Function; (validator: (value: any) => any): Function; ( arg: | string | RegExp | (string | RegExp)[] | { msg: string; args: string | RegExp | (string | RegExp)[] } ): Function;};
Adds custom validator
Parameter name
Name of validator
Parameter validator
Validator function
Adds custom validator
Parameter validator
Validator function
Will only allow values, that match the string regex or real regex
function IsAfter
IsAfter: (date: string) => Function;
Only allow date strings after a specific date
function IsAlpha
IsAlpha: (target: any, propertyName: string) => void;
Will only allow letters
function IsAlphanumeric
IsAlphanumeric: (target: any, propertyName: string) => void;
Will only allow alphanumeric characters, so "_abc" will fail
function IsArray
IsArray: (target: any, propertyName: string) => void;
Will only allow arrays
function IsBefore
IsBefore: (date: string) => Function;
Only allow date strings before a specific date
function IsCreditCard
IsCreditCard: (target: any, propertyName: string) => void;
Check for valid credit card numbers
function isDataType
isDataType: (value: any) => value is DataType;
function IsDate
IsDate: (target: any, propertyName: string) => void;
Only allow date strings
function IsDecimal
IsDecimal: (target: any, propertyName: string) => void;
Checks for any numbers
function IsEmail
IsEmail: (target: any, propertyName: string) => void;
Checks for email format (foo@bar.com)
function IsFloat
IsFloat: (target: any, propertyName: string) => void;
Checks for valid floating point numbers
function IsIn
IsIn: (arg: any[][] | { msg: string; args: any[][] }) => Function;
Check the value is one of these
function IsInt
IsInt: (target: any, propertyName: string) => void;
Checks for valid integers
function IsIP
IsIP: (target: any, propertyName: string) => void;
Checks for IPv4 (129.89.23.1) or IPv6 format
function IsIPv4
IsIPv4: (target: any, propertyName: string) => void;
Checks for IPv4 (129.89.23.1)
function IsIPv6
IsIPv6: (target: any, propertyName: string) => void;
Checks for IPv6 format
function IsLowercase
IsLowercase: (target: any, propertyName: string) => void;
Checks for lowercase
function IsNull
IsNull: (target: any, propertyName: string) => void;
Only allows null
function IsNumeric
IsNumeric: (target: any, propertyName: string) => void;
Will only allow numbers
function IsUppercase
IsUppercase: (target: any, propertyName: string) => void;
Checks for uppercase
function IsUrl
IsUrl: (target: any, propertyName: string) => void;
Checks for url format (http://foo.com)
function IsUUID
IsUUID: (version: 3 | 4 | 5 | '3' | '4' | '5' | 'all') => Function;
function Length
Length: ({ msg, min, max,}: { msg?: string; min?: number; max?: number;}) => Function;
Only allow values with length between min and max
function Max
Max: (limit: number) => Function;
Only allow values <= limit
function Min
Min: (limit: number) => Function;
Only allow values >= limit
function Not
Not: ( arg: | string | (string | RegExp)[] | RegExp | { msg: string; args: string | (string | RegExp)[] | RegExp }) => Function;
Will not allow values, that match the string regex or real regex
function NotContains
NotContains: (value: string | { msg: string; args: string }) => Function;
Don't allow specific substrings
function NotEmpty
NotEmpty: { (target: any, propertyName: string): void; (options: { msg: string }): Function;};
Don't allow empty strings
function NotIn
NotIn: (arg: any[][] | { msg: string; args: any[][] }) => Function;
Check the value is not one of these
function NotNull
NotNull: (target: any, propertyName: string) => void;
Won't allow null
function prepareArgs
prepareArgs: (...args: any[]) => { preparedArgs: any[]; options?: SequelizeOptions;};
function prepareOptions
prepareOptions: (options: SequelizeOptions) => SequelizeOptions;
Prepares sequelize config passed to original sequelize constructor
function PrimaryKey
PrimaryKey: (target: any, propertyName: string) => void;
Sets primary key option true for annotated property.
function resolveModelGetter
resolveModelGetter: (options: any) => any;
Resolves all model getters of specified options object recursively. So that {model: () => Person} will be converted to {model: Person}
function resolveScope
resolveScope: ( scopeName: string, model: ModelCtor, options: ScopesOptions) => void;
function resolveScopes
resolveScopes: (models: ModelCtor[]) => void;
Resolves scopes and adds them to the specified models
function resolvesDeprecatedScopes
resolvesDeprecatedScopes: (model: ModelCtor) => void;
Deprecated
function Scopes
Scopes: { (scopesGetter: ScopesOptionsGetter): Function; <TCreationAttributes extends {}, TModelAttributes extends {}>( scopes: ScopeTableOptions<TCreationAttributes, TModelAttributes> ): Function;};
Decorator for defining Model scopes
Decorator for defining Model scopes
Deprecated
function setAssociations
setAssociations: <TCreationAttributes extends {}, TModelAttributes extends {}>( target: any, associations: BaseAssociation<TCreationAttributes, TModelAttributes>[]) => void;
function setAttributes
setAttributes: (target: any, attributes: any) => void;
Sets attributes
function setHooks
setHooks: (target: any, hooks: HookMeta[]) => void;
Saves hooks meta data for the specified class
function setIndexes
setIndexes: (target: any, indexes: IndexesMeta) => void;
Sets indexes
function setModelName
setModelName: (target: any, modelName: string) => void;
Sets model name from class by storing this information through reflect metadata
function setOptions
setOptions: (target: any, options: ModelOptions<any>) => void;
Sets seuqlize define options to class prototype
function setScopeOptionsGetters
setScopeOptionsGetters: (target: any, options: ScopeOptionsGetters) => void;
function Table
Table: { <M extends Model<any, any> = Model<any, any>>( options: TableOptions<M> ): Function; (target: Function): void;};
function Unique
Unique: { (options: UniqueOptions): Function; (target: Object, propertyName: string): void;};
Sets unique option as specified in options and returns decorator
Decorator, which sets unique option true for annotated property.
function UpdatedAt
UpdatedAt: (target: any, propertyName: string) => void;
function Validate
Validate: (options: ModelValidateOptions) => Function;
Sets validation options for annotated field
function ValidationFailed
ValidationFailed: { (target: any, propertyName: string): void; (options: HookOptions): Function;};
function verbose
verbose: () => any;
Dummy database file, which gets required by sequelize, to make validation of models possible without using the actual ORM or any database connection.
Classes
class BaseAssociation
abstract class BaseAssociation< TCreationAttributes extends {}, TModelAttributes extends {}> {}
constructor
constructor( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options: any);
property options
protected options: any;
method getAs
getAs: () => string | { singular: string; plural: string } | undefined;
method getAssociatedClass
getAssociatedClass: () => ModelType<TCreationAttributes, TModelAttributes>;
method getAssociation
abstract getAssociation: () => Association;
method getSequelizeOptions
abstract getSequelizeOptions: ( model: ModelType<TCreationAttributes, TModelAttributes>, sequelize: Sequelize) => UnionAssociationOptions;
class BelongsToAssociation
class BelongsToAssociation< TCreationAttributes extends {}, TModelAttributes extends {}> extends BaseAssociation<TCreationAttributes, TModelAttributes> {}
constructor
constructor( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options: BelongsToOptions);
property options
protected options: BelongsToOptions;
method getAssociation
getAssociation: () => Association;
method getSequelizeOptions
getSequelizeOptions: ( model: ModelType<TCreationAttributes, TModelAttributes>) => UnionAssociationOptions;
class BelongsToManyAssociation
class BelongsToManyAssociation< TCreationAttributes extends {}, TModelAttributes extends {}, TCreationAttributesThrough extends {}, TModelAttributesThrough extends {}> extends BaseAssociation<TCreationAttributes, TModelAttributes> {}
constructor
constructor( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options: BelongsToManyOptions< TCreationAttributesThrough, TModelAttributesThrough >);
property options
protected options: BelongsToManyOptions< TCreationAttributesThrough, TModelAttributesThrough>;
method getAssociation
getAssociation: () => Association;
method getSequelizeOptions
getSequelizeOptions: ( model: ModelType<TCreationAttributes, TModelAttributes>, sequelize: Sequelize) => UnionAssociationOptions;
class HasAssociation
class HasAssociation< TCreationAttributes extends {}, TModelAttributes extends {}> extends BaseAssociation<TCreationAttributes, TModelAttributes> {}
constructor
constructor( associatedClassGetter: ModelClassGetter< TCreationAttributes, TModelAttributes >, options: any, association: Association);
property options
protected options: any;
method getAssociation
getAssociation: () => Association;
method getSequelizeOptions
getSequelizeOptions: ( model: ModelType<TCreationAttributes, TModelAttributes>) => UnionAssociationOptions;
class Model
abstract class Model< TModelAttributes extends {} = any, TCreationAttributes extends {} = TModelAttributes> extends OriginModel<TModelAttributes, TCreationAttributes> {}
constructor
constructor( values?: Utils.MakeNullishOptional<TCreationAttributes>, options?: BuildOptions);
property createdAt
createdAt?: any;
property deletedAt
deletedAt?: any;
property id
id?: any;
property isInitialized
static isInitialized: boolean;
property updatedAt
updatedAt?: any;
property version
version?: any;
method $add
$add: <R extends Model<any, any>>( propertyKey: string, instances: R | R[] | string[] | string | number[] | number, options?: AssociationActionOptions) => Promise<unknown>;
Adds relation between specified instances and source instance
method $count
$count: ( propertyKey: string, options?: AssociationCountOptions) => Promise<number>;
Counts related instances (specified by propertyKey) of source instance
method $create
$create: <R extends Model<any, any>>( propertyKey: string, values: any, options?: AssociationCreateOptions) => Promise<R>;
Creates instances and relate them to source instance
method $get
$get: <K extends keyof this>( propertyKey: K, options?: AssociationGetOptions) => Promise<$GetType<this[K]>>;
Returns related instance (specified by propertyKey) of source instance
method $has
$has: <R extends Model<any, any>>( propertyKey: string, instances: R | R[] | string[] | string | number[] | number, options?: AssociationGetOptions) => Promise<boolean>;
Checks if specified instances is related to source instance
method $remove
$remove: <R extends Model<any, any>>( propertyKey: string, instances: R | R[] | string[] | string | number[] | number, options?: any) => Promise<any>;
Removes specified instances from source instance
method $set
$set: <R extends Model<any, any>>( propertyKey: keyof this, instances: R | R[] | string[] | string | number[] | number | null, options?: AssociationActionOptions) => Promise<unknown>;
Sets relation between specified instances and source instance (replaces old relations)
method initialize
static initialize: < MS extends ModelStatic<Model<any, any>>, M extends InstanceType<MS>>( attributes: ModelAttributes, options: InitOptions) => MS;
method reload
reload: (options?: FindOptions) => Promise<this>;
class Sequelize
class Sequelize extends OriginSequelize {}
constructor
constructor( database: string, username: string, password?: string, options?: SequelizeOptions);
constructor
constructor(database: string, username: string, options?: SequelizeOptions);
constructor
constructor(options?: SequelizeOptions);
constructor
constructor(uri: string, options?: SequelizeOptions);
property options
options: SequelizeOptions;
property repositoryMode
repositoryMode: boolean;
method addModels
addModels: { (models: ModelCtor[]): void; (modelPaths: string[]): void; (modelPaths: string[], modelMatch?: ModelMatch): void; (arg: (string | ModelCtor<Model<any, any>>)[]): void;};
method getRepository
getRepository: <M extends Model<any, any>>( modelClass: new () => M) => Repository<M>;
method model
model: <TCreationAttributes extends {}, TModelAttributes extends {}>( model: string | ModelType<TCreationAttributes, TModelAttributes>) => ModelCtor;
Interfaces
interface AssociationActionOptions
interface AssociationActionOptions {}
property through
through?: any;
property transaction
transaction?: any;
property validate
validate?: boolean;
interface HookOptions
interface HookOptions {}
property name
name?: string;
interface IndexesMeta
interface IndexesMeta {}
interface IndexFieldOptions
interface IndexFieldOptions {}
interface ScopeOptions
interface ScopeOptions<TCreationAttributes extends {}, TModelAttributes extends {}> extends ScopeTableOptions<TCreationAttributes, TModelAttributes> {}
property defaultScope
defaultScope?: ScopeFindOptions<TCreationAttributes, TModelAttributes>;
interface ScopeOptionsGetters
interface ScopeOptionsGetters {}
property getDefaultScope
getDefaultScope?: DefaultScopeGetter;
property getScopes
getScopes?: ScopesOptionsGetter;
interface ScopeTableOptions
interface ScopeTableOptions< TCreationAttributes extends {}, TModelAttributes extends {}> {}
index signature
[scopeName: string]: | ScopeFindOptions<TCreationAttributes, TModelAttributes> | Function | undefined;
interface SequelizeOptions
interface SequelizeOptions extends Options {}
property modelMatch
modelMatch?: ModelMatch;
Matches models by filename using a custom function. (filename, member) => filename === member
property modelPaths
modelPaths?: string[];
Path to models, which should be loaded
Deprecated
property models
models?: string[] | ModelCtor[];
Path to models or actual models, which should be loaded for sequelize instance
property repositoryMode
repositoryMode?: boolean;
If true enables repository mode when true
property validateOnly
validateOnly?: boolean;
If true enables validate only mode
interface TableOptions
interface TableOptions<M extends Model = Model> extends ModelOptions<M> {}
property modelName
modelName?: string;
property version
version?: boolean | string;
Enable optimistic locking. When enabled, sequelize will add a version count attribute to the model and throw an OptimisticLockingError error when stale instances are saved. Set to true or a string with the attribute name you want to use to enable.
Enums
enum Association
enum Association { BelongsToMany = 'belongsToMany', BelongsTo = 'belongsTo', HasMany = 'hasMany', HasOne = 'hasOne',}
member BelongsTo
BelongsTo = 'belongsTo'
member BelongsToMany
BelongsToMany = 'belongsToMany'
member HasMany
HasMany = 'hasMany'
member HasOne
HasOne = 'hasOne'
Type Aliases
type $GetType
type $GetType<T> = NonNullable<T> extends any[] ? NonNullable<T> : NonNullable<T> | null;
type AssociationCountOptions
type AssociationCountOptions = { scope?: string | boolean;} & FindOptions;
type AssociationGetOptions
type AssociationGetOptions = { scope?: string | boolean; schema?: string;} & FindOptions;
type BelongsToManyOptions
type BelongsToManyOptions< TCreationAttributesThrough extends {}, TModelAttributesThrough extends {}> = { [K in keyof OriginBelongsToManyOptions]: K extends 'through' ? | ModelClassGetter<TCreationAttributesThrough, TModelAttributesThrough> | string | ThroughOptions<TCreationAttributesThrough, TModelAttributesThrough> : OriginBelongsToManyOptions[K];};
type DefaultScopeGetter
type DefaultScopeGetter = () => FindOptions;
type IndexOptions
type IndexOptions = Pick< SequelizeIndexOptions, Exclude<keyof SequelizeIndexOptions, 'fields'>>;
type ModelClassGetter
type ModelClassGetter< TCreationAttributes extends {}, TModelAttributes extends {}> = (returns?: void) => ModelType<TCreationAttributes, TModelAttributes>;
type ModelCtor
type ModelCtor<M extends Model = Model> = Repository<M>;
type ModelMatch
type ModelMatch = (filename: string, member: string) => boolean;
type ModelStatic
type ModelStatic<M extends Model = Model> = { new (): M;};
type ModelType
type ModelType<TCreationAttributes extends {}, TModelAttributes extends {}> = new ( values?: TCreationAttributes, options?: any) => Model<TModelAttributes, TCreationAttributes>;
type NonBelongsToManyAssociationOptions
type NonBelongsToManyAssociationOptions = | BelongsToOptions | HasManyOptions | HasOneOptions | ManyToManyOptions;
type Repository
type Repository<M> = (new () => M) & NonAbstract<typeof Model>;
type ScopesOptions
type ScopesOptions = FindOptions | ((...args: any[]) => FindOptions);
type ScopesOptionsGetter
type ScopesOptionsGetter = () => { [sopeName: string]: ScopesOptions;};
type ThroughOptions
type ThroughOptions<TCreationAttributes extends {}, TModelAttributes extends {}> = { [K in keyof OriginThroughOptions]: K extends 'model' ? ModelClassGetter<TCreationAttributes, TModelAttributes> | string : OriginThroughOptions[K];};
type UnionAssociationOptions
type UnionAssociationOptions = | BelongsToOptions | HasManyOptions | HasOneOptions | ManyToManyOptions;
Package Files (123)
- dist/associations/belongs-to-many/belongs-to-many-association.d.ts
- dist/associations/belongs-to-many/belongs-to-many-options.d.ts
- dist/associations/belongs-to-many/belongs-to-many.d.ts
- dist/associations/belongs-to/belongs-to-association.d.ts
- dist/associations/belongs-to/belongs-to.d.ts
- dist/associations/foreign-key/foreign-key.d.ts
- dist/associations/has/has-association.d.ts
- dist/associations/has/has-many.d.ts
- dist/associations/has/has-one.d.ts
- dist/associations/shared/association-service.d.ts
- dist/associations/shared/association.d.ts
- dist/associations/shared/base-association.d.ts
- dist/associations/shared/union-association-options.d.ts
- dist/associations/through/through-options.d.ts
- dist/hooks/bulk/after/after-bulk-create.d.ts
- dist/hooks/bulk/after/after-bulk-destroy.d.ts
- dist/hooks/bulk/after/after-bulk-restore.d.ts
- dist/hooks/bulk/after/after-bulk-sync.d.ts
- dist/hooks/bulk/after/after-bulk-update.d.ts
- dist/hooks/bulk/before/before-bulk-create.d.ts
- dist/hooks/bulk/before/before-bulk-destroy.d.ts
- dist/hooks/bulk/before/before-bulk-restore.d.ts
- dist/hooks/bulk/before/before-bulk-sync.d.ts
- dist/hooks/bulk/before/before-bulk-update.d.ts
- dist/hooks/shared/hook-options.d.ts
- dist/hooks/shared/hooks-service.d.ts
- dist/hooks/shared/validation-failed.d.ts
- dist/hooks/single/after/after-connect.d.ts
- dist/hooks/single/after/after-create.d.ts
- dist/hooks/single/after/after-define.d.ts
- dist/hooks/single/after/after-destroy.d.ts
- dist/hooks/single/after/after-find.d.ts
- dist/hooks/single/after/after-init.d.ts
- dist/hooks/single/after/after-restore.d.ts
- dist/hooks/single/after/after-save.d.ts
- dist/hooks/single/after/after-sync.d.ts
- dist/hooks/single/after/after-update.d.ts
- dist/hooks/single/after/after-upsert.d.ts
- dist/hooks/single/after/after-validate.d.ts
- dist/hooks/single/before/before-connect.d.ts
- dist/hooks/single/before/before-count.d.ts
- dist/hooks/single/before/before-create.d.ts
- dist/hooks/single/before/before-define.d.ts
- dist/hooks/single/before/before-destroy.d.ts
- dist/hooks/single/before/before-find-after-expand-include-all.d.ts
- dist/hooks/single/before/before-find-after-options.d.ts
- dist/hooks/single/before/before-find.d.ts
- dist/hooks/single/before/before-init.d.ts
- dist/hooks/single/before/before-restore.d.ts
- dist/hooks/single/before/before-save.d.ts
- dist/hooks/single/before/before-sync.d.ts
- dist/hooks/single/before/before-update.d.ts
- dist/hooks/single/before/before-upsert.d.ts
- dist/hooks/single/before/before-validate.d.ts
- dist/index.d.ts
- dist/model/column/attribute-service.d.ts
- dist/model/column/column-options/allow-null.d.ts
- dist/model/column/column-options/comment.d.ts
- dist/model/column/column-options/default.d.ts
- dist/model/column/column-options/unique.d.ts
- dist/model/column/column.d.ts
- dist/model/column/primary-key/auto-increment.d.ts
- dist/model/column/primary-key/primary-key.d.ts
- dist/model/column/timestamps/created-at.d.ts
- dist/model/column/timestamps/deleted-at.d.ts
- dist/model/column/timestamps/updated-at.d.ts
- dist/model/index/create-index-decorator.d.ts
- dist/model/index/index-decorator.d.ts
- dist/model/index/index-service.d.ts
- dist/model/model/association/association-action-options.d.ts
- dist/model/model/association/association-count-options.d.ts
- dist/model/model/association/association-get-options.d.ts
- dist/model/model/model.d.ts
- dist/model/shared/model-class-getter.d.ts
- dist/model/shared/model-service.d.ts
- dist/model/table/table-options.d.ts
- dist/model/table/table.d.ts
- dist/scopes/default-scope.d.ts
- dist/scopes/scope-options.d.ts
- dist/scopes/scope-service.d.ts
- dist/scopes/scope-table-options.d.ts
- dist/scopes/scopes.d.ts
- dist/sequelize/data-type/data-type-service.d.ts
- dist/sequelize/data-type/data-type.d.ts
- dist/sequelize/repository/repository.d.ts
- dist/sequelize/sequelize/sequelize-options.d.ts
- dist/sequelize/sequelize/sequelize-service.d.ts
- dist/sequelize/sequelize/sequelize.d.ts
- dist/sequelize/validation-only/db-dialect-dummy.d.ts
- dist/validation/contains.d.ts
- dist/validation/equals.d.ts
- dist/validation/is-after.d.ts
- dist/validation/is-alpha.d.ts
- dist/validation/is-alphanumeric.d.ts
- dist/validation/is-array.d.ts
- dist/validation/is-before.d.ts
- dist/validation/is-credit-card.d.ts
- dist/validation/is-date.d.ts
- dist/validation/is-decimal.d.ts
- dist/validation/is-email.d.ts
- dist/validation/is-float.d.ts
- dist/validation/is-in.d.ts
- dist/validation/is-int.d.ts
- dist/validation/is-ip-v4.d.ts
- dist/validation/is-ip-v6.d.ts
- dist/validation/is-ip.d.ts
- dist/validation/is-lowercase.d.ts
- dist/validation/is-null.d.ts
- dist/validation/is-numeric.d.ts
- dist/validation/is-uppercase.d.ts
- dist/validation/is-url.d.ts
- dist/validation/is-uuid.d.ts
- dist/validation/is.d.ts
- dist/validation/length.d.ts
- dist/validation/max.d.ts
- dist/validation/min.d.ts
- dist/validation/not-contains.d.ts
- dist/validation/not-empty.d.ts
- dist/validation/not-in.d.ts
- dist/validation/not-null.d.ts
- dist/validation/not.d.ts
- dist/validation/validate.d.ts
- dist/validation/validator.d.ts
Dependencies (1)
Dev Dependencies (43)
- @commitlint/cli
- @commitlint/config-conventional
- @release-it/conventional-changelog
- @types/chai
- @types/chai-as-promised
- @types/chai-datetime
- @types/lodash
- @types/mocha
- @types/node
- @types/prettyjson
- @types/sinon
- @types/sinon-chai
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- chai
- chai-as-promised
- chai-datetime
- codecov
- copyfiles
- eslint
- eslint-config-prettier
- eslint-plugin-prettier
- has-flag
- husky
- lodash
- markdownlint-cli
- mocha
- moment
- mysql2
- nyc
- pinst
- prettier
- prettyjson
- reflect-metadata
- release-it
- sequelize
- sinon
- sinon-chai
- source-map-support
- sqlite3
- ts-node
- typescript
- uuid-validate
Peer Dependencies (4)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/sequelize-typescript
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/sequelize-typescript)
- HTML<a href="https://www.jsdocs.io/package/sequelize-typescript"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6234 ms. - Missing or incorrect documentation? Open an issue for this package.