LoopBack 3 has reached end of life. We are no longer accepting pull requests or providing support for community users. The only exception is fixes for critical bugs and security vulnerabilities provided as part of support for IBM API Connect customers. We urge all LoopBack 3 users to migrate their applications to LoopBack 4 as soon as possible. Learn more about LoopBack's long term support policy.

Executing native SQL

Edit this page
Page Contents


Warning: 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.execute(sql_stmt, params, callback);

or

dataSource.connector.query(sql_stmt, params, callback); // For 1.x connectors

Where:

  • sql_stmt - The SQL string.
  • params - parameters to the SQL statement.
  • callback - callback function

Important:

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.


AltStyle によって変換されたページ (->オリジナル) /