Skip to main content

Execute

Executes a raw SQL statement and returns the result.

  • Parameters:
    • sql: The SQL statement to execute.
    • params: Optional parameters to bind to the SQL statement.
  • Returns:
    • The result of the operation, includes the result of the SQL query or an error if the operation failed.
// Execute a SELECT statement and get results
const result = db.execute("SELECT * FROM miftahdb WHERE key LIKE ? LIMIT 5;", [
"%",
]);

if (result.success) {
console.log(result.data);
} else {
console.log(result.error.message);
}