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.