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_, _params_, _cb_);
or
dataSource.connector.query(_sql_, _params_, _cb_); // For 1.x connectors
Where:
- sql - The SQL string.
- params - parameters to the SQL statement.
- cb - 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.