Options
All
  • Public
  • Public/Protected
  • All
Menu

Sequelize methods available only for the static class ( basically this is the constructor and some extends )

Hierarchy

Index

Constructors

constructor

  • new SequelizeStatic(database: string, username: string, password: string, options?: Options): Sequelize
  • new SequelizeStatic(database: string, username: string, options?: Options): Sequelize
  • new SequelizeStatic(uri: string, options?: Options): Sequelize
  • Instantiate sequelize with name of database, username and password

    Example usage

    // without password and options
    var sequelize = new Sequelize('database', 'username')
    
    // without options
    var sequelize = new Sequelize('database', 'username', 'password')
    
    // without password / with blank password
    var sequelize = new Sequelize('database', 'username', null, {})
    
    // with password and options
    var sequelize = new Sequelize('my_database', 'john', 'doe', {})
    
    // with uri (see below)
    var sequelize = new Sequelize('mysql://localhost:3306/database', {})
    

    Parameters

    • database: string

      The name of the database

    • username: string

      The username which is used to authenticate against the database.

    • password: string

      The password which is used to authenticate against the database.

    • Optional options: Options

      An object with options.

    Returns Sequelize

  • Instantiate sequelize with name of database, username and password Instantiate sequelize with an URI

    Example usage

    // without password and options
    var sequelize = new Sequelize('database', 'username')
    
    // without options
    var sequelize = new Sequelize('database', 'username', 'password')
    
    // without password / with blank password
    var sequelize = new Sequelize('database', 'username', null, {})
    
    // with password and options
    var sequelize = new Sequelize('my_database', 'john', 'doe', {})
    
    // with uri (see below)
    var sequelize = new Sequelize('mysql://localhost:3306/database', {})
    

    Parameters

    • database: string

      The name of the database

    • username: string

      The username which is used to authenticate against the database.

    • Optional options: Options

      An object with options.

    Returns Sequelize

  • Instantiate sequelize with an URI

    Example usage

    // without password and options
    var sequelize = new Sequelize('database', 'username')
    
    // without options
    var sequelize = new Sequelize('database', 'username', 'password')
    
    // without password / with blank password
    var sequelize = new Sequelize('database', 'username', null, {})
    
    // with password and options
    var sequelize = new Sequelize('my_database', 'john', 'doe', {})
    
    // with uri (see below)
    var sequelize = new Sequelize('mysql://localhost:3306/database', {})
    
    name

    Sequelize

    constructor

    Parameters

    • uri: string

      A full database URI

    • Optional options: Options

      An object with options.

    Returns Sequelize

Properties

ABSTRACT

ARRAY

AccessDeniedError

AccessDeniedError: AccessDeniedError

BIGINT

BLOB

BOOLEAN

CHAR

ConnectionError

ConnectionError: ConnectionError

ConnectionRefusedError

ConnectionRefusedError: ConnectionRefusedError

ConnectionTimedOutError

ConnectionTimedOutError: ConnectionTimedOutError

DATE

DATEONLY

DECIMAL

DOUBLE

DOUBLE PRECISION

DOUBLE PRECISION: DataTypeDouble

DatabaseError

DatabaseError: DatabaseError

Deferrable

Deferrable: Deferrable

A reference to the deferrable collection. Use this to access the different deferrable options.

ENUM

Error

Error: BaseError

ExclusionConstraintError

ExclusionConstraintError: ExclusionConstraintError

FLOAT

ForeignKeyConstraintError

ForeignKeyConstraintError: ForeignKeyConstraintError

GEOMETRY

HSTORE

HostNotFoundError

HostNotFoundError: HostNotFoundError

HostNotReachableError

HostNotReachableError: HostNotReachableError

INTEGER

Instance

Instance: Instance<any>

A reference to the sequelize instance class.

InvalidConnectionError

InvalidConnectionError: InvalidConnectionError

JSON

JSONB

Model

Model: Model<any, any>

A Model represents a table in the database. Sometimes you might also see it referred to as model, or simply as factory. This class should not be instantiated directly, it is created using sequelize.define, and already created models can be loaded using sequelize.import

NONE

NOW

NUMBER

NUMERIC

Promise

Promise: PromiseConstructor

A modified version of bluebird promises, that allows listening for sql events

QueryTypes

QueryTypes: QueryTypes

Available query types for use with sequelize.query

RANGE

REAL

STRING

TEXT

TIME

TimeoutError

TimeoutError: TimeoutError

Transaction

Transaction: TransactionStatic

A reference to the sequelize transaction class. Use this to access isolationLevels when creating a transaction

UUID

UUIDV1

UUIDV4

UniqueConstraintError

UniqueConstraintError: UniqueConstraintError

Utils

Utils: Utils

A reference to sequelize utilities. Most users will not need to use these utils directly. However, you might want to use Sequelize.Utils._, which is a reference to the lodash library, if you don't already have it imported in your project.

VIRTUAL

ValidationError

ValidationError: ValidationError

ValidationErrorItem

ValidationErrorItem: ValidationErrorItem

Validator

Validator: Validator

Exposes the validator.js object, so you can extend it with custom validation functions. The validator is exposed both on the instance, and on the constructor.

cls

cls: any

Methods

and

  • and(...args: Array<string | Object>): and
  • An AND query

    Parameters

    • Rest ...args: Array<string | Object>

      Each argument will be joined by AND

    Returns and

asIs

cast

  • cast(val: any, type: string): cast
  • Creates a object representing a call to the cast function.

    Parameters

    • val: any

      The value to cast

    • type: string

      The type to cast it to

    Returns cast

col

  • col(col: string): col
  • Creates a object representing a column in the DB. This is often useful in conjunction with sequelize.fn, since raw string arguments to fn will be escaped.

    Parameters

    • col: string

      The name of the column

    Returns col

condition

  • condition(attr: Object, logic: string | Object): where

fn

  • fn(fn: string, ...args: any[]): fn
  • Creates a object representing a database function. This can be used in search queries, both in where and order parts, and as default values in column definitions. If you want to refer to columns in your function, you should use sequelize.col, so that the columns are properly interpreted as columns and not a strings.

    Convert a user's username to upper case

    instance.updateAttributes({
      username: self.sequelize.fn('upper', self.sequelize.col('username'))
    })
    

    Parameters

    • fn: string

      The function you want to call

    • Rest ...args: any[]

      All further arguments will be passed as arguments to the function

    Returns fn

json

  • json(conditionsOrPath: string | Object, value?: string | number | boolean): json
  • Creates an object representing nested where conditions for postgres's json data-type.

    Parameters

    • conditionsOrPath: string | Object

      A hash containing strings/numbers or other nested hash, a string using dot notation or a string using postgres json syntax.

    • Optional value: string | number | boolean

      An optional value to compare against. Produces a string of the form " = ''".

    Returns json

literal

  • Creates a object representing a literal, i.e. something that will not be escaped.

    Parameters

    • val: any

    Returns literal

or

  • or(...args: Array<string | Object>): or
  • An OR query

    Parameters

    • Rest ...args: Array<string | Object>

      Each argument will be joined by OR

    Returns or

where

  • where(attr: Object, comparator: string, logic: string | Object): where
  • where(attr: Object, logic: string | Object): where
  • A way of specifying attr = condition.

    The attr can either be an object taken from Model.rawAttributes (for example Model.rawAttributes.id or Model.rawAttributes.name). The attribute should be defined in your model definition. The attribute can also be an object from one of the sequelize utility functions (sequelize.fn, sequelize.col etc.)

    For string attributes, use the regular { where: { attr: something }} syntax. If you don't want your string to be escaped, use sequelize.literal.

    Parameters

    • attr: Object

      The attribute, which can be either an attribute object from Model.rawAttributes or a sequelize object, for example an instance of sequelize.fn. For simple string attributes, use the POJO syntax

    • comparator: string

      Comparator

    • logic: string | Object

      The condition. Can be both a simply type, or a further condition (.or, .and, .literal etc.)

    Returns where

  • Parameters

    • attr: Object
    • logic: string | Object

    Returns where

Generated using TypeDoc