Skip to content

loopback4-sequelize / SequelizeDataSource

Class: SequelizeDataSource

Sequelize DataSource Class

Implements

  • LifeCycleObserver

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new SequelizeDataSource(config)

Parameters

Name Type
config SequelizeDataSourceConfig

Defined in

src/sequelize/sequelize.datasource.base.ts:37

Properties

config

config: SequelizeDataSourceConfig

Defined in

src/sequelize/sequelize.datasource.base.ts:37


name

name: string

Defined in

src/sequelize/sequelize.datasource.base.ts:35


sequelize

Optional sequelize: Sequelize

Defined in

src/sequelize/sequelize.datasource.base.ts:50


sequelizeConfig

sequelizeConfig: Options

Defined in

src/sequelize/sequelize.datasource.base.ts:51


settings

settings: Object = {}

Defined in

src/sequelize/sequelize.datasource.base.ts:36

Methods

automigrate

automigrate(): void

Returns

void

Defined in

src/sequelize/sequelize.datasource.base.ts:94


autoupdate

autoupdate(): void

Returns

void

Defined in

src/sequelize/sequelize.datasource.base.ts:99


beginTransaction

beginTransaction(options?): Promise<Transaction>

Begin a new transaction.

Parameters

Name Type Description
options? TransactionOptions | ISOLATION_LEVELS Options {isolationLevel: '...'}

Returns

Promise<Transaction>

A promise which resolves to a Sequelize Transaction object

Defined in

src/sequelize/sequelize.datasource.base.ts:111


execute

execute(command, parameters?, options?): Promise<AnyObject>

Execute a SQL command.

WARNING: In general, it is always better to perform database actions through repository methods. Directly executing SQL may lead to unexpected results, corrupted data, security vulnerabilities and other issues.

Example

// MySQL
const result = await repo.execute(
  'SELECT * FROM Products WHERE size > ?',
  [42]
);

// PostgreSQL
const result = await repo.execute(
  'SELECT * FROM Products WHERE size > $1',
  [42]
);

Parameters

Name Type Description
command Command A parameterized SQL command or query.
parameters? AnyObject | PositionalParameters List of parameter values to use.
options? AnyObject Additional options, for example transaction.

Returns

Promise<AnyObject>

A promise which resolves to the command output. The output type (data structure) is database specific and often depends on the command executed.

Defined in

src/sequelize/sequelize.datasource.base.ts:166


getPoolOptions

getPoolOptions(): undefined | PoolOptions

Returns

undefined | PoolOptions

Defined in

src/sequelize/sequelize.datasource.base.ts:212


init

init(): Promise<void>

Returns

Promise<void>

Implementation of

LifeCycleObserver.init

Defined in

src/sequelize/sequelize.datasource.base.ts:52


start

start(..._injectedArgs): Promise<void>

Parameters

Name Type
..._injectedArgs unknown[]

Returns

Promise<void>

Implementation of

LifeCycleObserver.start

Defined in

src/sequelize/sequelize.datasource.base.ts:89


stop

stop(): Promise<void>

Returns

Promise<void>

Implementation of

LifeCycleObserver.stop

Defined in

src/sequelize/sequelize.datasource.base.ts:90