Page Contents

Home > @loopback/sequelize > SequelizeCrudRepository > execute

SequelizeCrudRepository.execute() method

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.


execute(command: Command, parameters?: NamedParameters | PositionalParameters, options?: Options): Promise<AnyObject>;


Parameter Type Description
command Command A parameterized SQL command or query.
parameters NamedParameters | PositionalParameters (Optional) List of parameter values to use.
options Options (Optional) Additional options, for example transaction.



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


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

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