| 183 | } |
| 184 | |
| 185 | async fn execute(&self, statement: Statement) -> Result<ProxyExecResult, DbErr> { |
| 186 | console_log!("SQL execute: {:?}", statement); |
| 187 | |
| 188 | let env = self.env.clone(); |
| 189 | let (tx, rx) = oneshot::channel(); |
| 190 | wasm_bindgen_futures::spawn_local(async move { |
| 191 | let ret = Self::do_execute(env, statement).await; |
| 192 | tx.send(ret).unwrap(); |
| 193 | }); |
| 194 | |
| 195 | let ret = rx.await.unwrap(); |
| 196 | ret.map_err(|err| DbErr::Conn(RuntimeErr::Internal(err.to_string()))) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | pub async fn init_db(env: Arc<Env>) -> Result<DatabaseConnection> { |