MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / init_db

Function init_db

examples/proxy_cloudflare_worker_example/src/orm.rs:200–218  ·  view source on GitHub ↗
(env: Arc<Env>)

Source from the content-addressed store, hash-verified

198}
199
200pub async fn init_db(env: Arc<Env>) -> Result<DatabaseConnection> {
201 let db = Database::connect_proxy(DbBackend::Sqlite, Arc::new(Box::new(ProxyDb { env })))
202 .await
203 .context("Failed to connect to database")?;
204 let builder = db.get_database_backend();
205
206 console_log!("Connected to database");
207
208 db.execute(
209 builder.build(
210 Schema::new(builder)
211 .create_table_from_entity(crate::entity::Entity)
212 .if_not_exists(),
213 ),
214 )
215 .await?;
216
217 Ok(db)
218}

Callers 2

handler_getFunction · 0.85
handler_generateFunction · 0.85

Calls 5

newFunction · 0.50
get_database_backendMethod · 0.45
executeMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected