|
|
|
@ -1,4 +1,4 @@ |
|
|
|
use sqlx::{pool::PoolConnection, prelude::*, query, query_as, query_file, SqliteConnection, SqlitePool}; |
|
|
|
use sqlx::{pool::PoolConnection, prelude::*, query_unchecked, query_as, query_file_unchecked, SqliteConnection, SqlitePool}; |
|
|
|
use tokio::stream::StreamExt; |
|
|
|
|
|
|
|
pub mod types; |
|
|
|
@ -14,7 +14,7 @@ impl DbPool { |
|
|
|
|
|
|
|
let mut conn = pool.acquire().await.unwrap(); |
|
|
|
|
|
|
|
query_file!("src/setup.sql") |
|
|
|
query_file_unchecked!("src/setup.sql") |
|
|
|
.execute(&mut conn) |
|
|
|
.await |
|
|
|
.unwrap(); |
|
|
|
@ -50,7 +50,7 @@ impl DbConnection { |
|
|
|
let uuid = Uuid::new_v4(); |
|
|
|
// println!("{:?}", uuid.as_bytes().to_vec());
|
|
|
|
self.conn |
|
|
|
.execute(query!( |
|
|
|
.execute(query_unchecked!( |
|
|
|
"INSERT INTO Users(uuid, name) VALUES(?, ?)", |
|
|
|
uuid.as_bytes().to_vec(), |
|
|
|
name.to_string() |
|
|
|
@ -70,7 +70,7 @@ impl DbConnection { |
|
|
|
pub async fn create_lobby(&mut self) -> u32 { |
|
|
|
let id = rand::random(); |
|
|
|
self.conn |
|
|
|
.execute(query!( |
|
|
|
.execute(query_unchecked!( |
|
|
|
"INSERT INTO Lobbies(id) VALUES(?)", |
|
|
|
id as i32 |
|
|
|
)) |
|
|
|
@ -81,7 +81,7 @@ impl DbConnection { |
|
|
|
|
|
|
|
pub async fn join_lobby(&mut self, user: Uuid, lobby: u32) { |
|
|
|
self.conn |
|
|
|
.execute(query!( |
|
|
|
.execute(query_unchecked!( |
|
|
|
"INSERT INTO UsersInLobbies(UserId, LobbyId) VALUES(?, ?)", |
|
|
|
user.as_bytes().to_vec(), |
|
|
|
lobby as i32 |
|
|
|
|