Chinese Documentation : Executing native SQL

Icon

This feature has not been fully tested and is not officially supported: the API may change in future releases.

In general, it is always better to perform database actions through connected models. Directly executing SQL may lead to unexpected results, corrupted data, and other issues.

To execute SQL directly against your data-connected model, use the following:

dataSource.connector.query(sql, params, cb);

Where:

  • sql - The SQL string.
  • params - parameters to the SQL statement.
  • cb - callback function
Icon

The actual method signature depends on the specific connector being used. See connector source code. For example, loopback-connector-mysql.

Use caution and be advised that the API may change in the future.