Static
loadStatic
getget
A static initializer which synchronously returns an instance of the Database class while deferring the actual database connection until the first invocation or selection on the database.
The path is relative to tauri::path::BaseDirectory::App
and must start with sqlite:
.
execute
Passes a SQL expression to the database for execution.
Optional
bindValues: unknown[]// for sqlite & postgres
// INSERT example
const result = await db.execute(
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
[ todos.id, todos.title, todos.status ]
);
// UPDATE example
const result = await db.execute(
"UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
[ todos.title, todos.status, todos.id ]
);
// for mysql
// INSERT example
const result = await db.execute(
"INSERT into todos (id, title, status) VALUES (?, ?, ?)",
[ todos.id, todos.title, todos.status ]
);
// UPDATE example
const result = await db.execute(
"UPDATE todos SET title = ?, completed = ? WHERE id = ?",
[ todos.title, todos.status, todos.id ]
);
close
Closes the database connection pool.
Optional
db: stringOptionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
Database
The
Database
class serves as the primary interface for communicating with the rust side of the sql plugin.