mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-09-15 22:32:04 +02:00
Database access refactor (#190)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
use crate::error::Result;
|
||||
use crate::manager::QueryManagerExt;
|
||||
use crate::models::AnyModel;
|
||||
use crate::queries_legacy::UpdateSource;
|
||||
use tauri::{Runtime, WebviewWindow};
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) async fn upsert<R: Runtime>(
|
||||
window: WebviewWindow<R>,
|
||||
model: AnyModel,
|
||||
) -> Result<String> {
|
||||
let queries = window.queries().connect().await?;
|
||||
let id = match model {
|
||||
AnyModel::HttpRequest(r) => queries.upsert(&r, &UpdateSource::from_window(&window))?.id,
|
||||
_ => todo!(),
|
||||
};
|
||||
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn delete() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user