feat: add surreal db
This commit is contained in:
23
src-tauri/src/commands/db.rs
Normal file
23
src-tauri/src/commands/db.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use crate::model::*;
|
||||
use crate::AppState;
|
||||
use tauri::State;
|
||||
|
||||
#[tauri::command(async)]
|
||||
pub async fn create_account(
|
||||
pubkey: String,
|
||||
app_state: State<'_, AppState>,
|
||||
) -> Result<Vec<Record>, ()> {
|
||||
let db = app_state.db.lock().await;
|
||||
|
||||
let created: Vec<Record> = db
|
||||
.create("account")
|
||||
.content(Account {
|
||||
id: None,
|
||||
pubkey,
|
||||
is_active: true,
|
||||
})
|
||||
.await
|
||||
.expect("Create account failed");
|
||||
|
||||
Ok(created)
|
||||
}
|
||||
Reference in New Issue
Block a user