pub struct Builder { /* private fields */ }Expand description
Tauri SQL plugin builder.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder with no migrations registered.
Prints a message to stderr when none of the sqlite, mysql and
postgres Cargo features is enabled, since no database can be
connected to in that case.
Sourcepub fn add_migrations(self, db_url: &str, migrations: Vec<Migration>) -> Self
pub fn add_migrations(self, db_url: &str, migrations: Vec<Migration>) -> Self
Add migrations to a database.
Sourcepub fn build<R: Runtime>(self) -> TauriPlugin<R, Option<PluginConfig>>
pub fn build<R: Runtime>(self) -> TauriPlugin<R, Option<PluginConfig>>
Builds the SQL plugin.
On setup the plugin connects to every database listed in the preload
array of its configuration, running the migrations
registered for them, and it closes all connection pools when the
application exits.
§Examples
use tauri_plugin_sql::{Builder, Migration, MigrationKind};
fn sql_plugin<R: tauri::Runtime>(
) -> tauri::plugin::TauriPlugin<R, Option<tauri_plugin_sql::PluginConfig>> {
Builder::new()
.add_migrations(
"sqlite:mydatabase.db",
vec![Migration {
version: 1,
description: "create todos table",
sql: "CREATE TABLE todos (id INTEGER PRIMARY KEY, title TEXT);",
kind: MigrationKind::Up,
}],
)
.build()
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more