default
Defined in: index.ts:27
Database
The Database
class serves as the primary interface for
communicating with the rust side of the sql plugin.
new default(
path
):Database
Defined in: index.ts:29
string
Database
path:
string
Defined in: index.ts:28
close(
db?
):Promise
<boolean
>
Defined in: index.ts:162
close
Closes the database connection pool.
string
Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
Promise
<boolean
>
const success = await db.close()
execute(
query
,bindValues?
):Promise
<QueryResult
>
Defined in: index.ts:108
execute
Passes a SQL expression to the database for execution.
string
unknown
[]
Promise
<QueryResult
>
// for sqlite & postgres// INSERT exampleconst result = await db.execute( "INSERT into todos (id, title, status) VALUES ($1, $2, $3)", [ todos.id, todos.title, todos.status ]);// UPDATE exampleconst result = await db.execute( "UPDATE todos SET title = $1, completed = $2 WHERE id = $3", [ todos.title, todos.status, todos.id ]);
// for mysql// INSERT exampleconst result = await db.execute( "INSERT into todos (id, title, status) VALUES (?, ?, ?)", [ todos.id, todos.title, todos.status ]);// UPDATE exampleconst result = await db.execute( "UPDATE todos SET title = ?, completed = ? WHERE id = ?", [ todos.title, todos.status, todos.id ]);
select<
T
>(query
,bindValues?
):Promise
<T
>
Defined in: index.ts:141
select
Passes in a SELECT query to the database for execution.
T
string
unknown
[]
Promise
<T
>
// for sqlite & postgresconst result = await db.select( "SELECT * from todos WHERE id = $1", [ id ]);
// for mysqlconst result = await db.select( "SELECT * from todos WHERE id = ?", [ id ]);
static
get(path
):Database
Defined in: index.ts:72
get
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:
.
string
Database
const db = Database.get("sqlite:test.db");
static
load(path
):Promise
<Database
>
Defined in: index.ts:48
load
A static initializer which connects to the underlying database and
returns a Database
instance once a connection to the database is established.
The path is relative to tauri::path::BaseDirectory::App
and must start with sqlite:
.
string
Promise
<Database
>
const db = await Database.load("sqlite:test.db");
© 2025 Tauri Contributors. CC-BY / MIT