@@ -118,6 +118,7 @@ fn run_async_command<F: std::future::Future>(cmd: F) -> F::Output {
118
118
#[ derive( Default ) ]
119
119
pub struct Builder {
120
120
migrations : Option < HashMap < String , MigrationList > > ,
121
+ options : Option < HashMap < String , ConnectionOptions > > ,
121
122
}
122
123
123
124
impl Builder {
@@ -137,6 +138,15 @@ impl Builder {
137
138
self
138
139
}
139
140
141
+ /// Set database options.
142
+ #[ must_use]
143
+ pub fn set_options ( mut self , db_url : & str , connection_options : ConnectionOptions ) -> Self {
144
+ self . options
145
+ . get_or_insert ( Default :: default ( ) )
146
+ . insert ( db_url. to_string ( ) , connection_options) ;
147
+ self
148
+ }
149
+
140
150
pub fn build < R : Runtime > ( mut self ) -> TauriPlugin < R , Option < PluginConfig > > {
141
151
PluginBuilder :: < R , Option < PluginConfig > > :: new ( "sql" )
142
152
. invoke_handler ( tauri:: generate_handler![
@@ -153,7 +163,7 @@ impl Builder {
153
163
let mut lock = instances. 0 . write ( ) . await ;
154
164
155
165
for db in config. preload {
156
- let pool = DbPool :: connect ( & db, app, None ) . await ?;
166
+ let pool = DbPool :: connect ( & db, app, self . options . as_mut ( ) . and_then ( |mm| mm . remove ( & db ) ) ) . await ?;
157
167
158
168
if let Some ( migrations) =
159
169
self . migrations . as_mut ( ) . and_then ( |mm| mm. remove ( & db) )
0 commit comments