- Add filter and sort parameters to MongoDB find_documents across the full stack (driver, ops, tauri cmd, web routes, frontend API) - Add find/sort input bar to MongoDocBrowser table view via DataGrid search-bar slot, matching WHERE/ORDER BY positioning - Fix table view editing: allow cell editing when customSave is provided (bypasses primary key requirement for MongoDB) - Fix replace_one WriteError 66 by removing _id from replacement doc - Align action buttons (refresh, add row, commit) to the right in grid
82 lines
2.1 KiB
Rust
82 lines
2.1 KiB
Rust
use std::sync::Arc;
|
|
use tauri::State;
|
|
|
|
use crate::commands::connection::AppState;
|
|
use dbx_core::db::mongo_driver::MongoDocumentResult;
|
|
|
|
#[tauri::command]
|
|
pub async fn mongo_list_databases(
|
|
state: State<'_, Arc<AppState>>,
|
|
connection_id: String,
|
|
) -> Result<Vec<String>, String> {
|
|
dbx_core::mongo_ops::mongo_list_databases_core(&state, &connection_id).await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn mongo_list_collections(
|
|
state: State<'_, Arc<AppState>>,
|
|
connection_id: String,
|
|
database: String,
|
|
) -> Result<Vec<String>, String> {
|
|
dbx_core::mongo_ops::mongo_list_collections_core(&state, &connection_id, &database).await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn mongo_find_documents(
|
|
state: State<'_, Arc<AppState>>,
|
|
connection_id: String,
|
|
database: String,
|
|
collection: String,
|
|
skip: u64,
|
|
limit: i64,
|
|
filter: Option<String>,
|
|
sort: Option<String>,
|
|
) -> Result<MongoDocumentResult, String> {
|
|
dbx_core::mongo_ops::mongo_find_documents_core(
|
|
&state,
|
|
&connection_id,
|
|
&database,
|
|
&collection,
|
|
skip,
|
|
limit,
|
|
filter.as_deref(),
|
|
sort.as_deref(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn mongo_insert_document(
|
|
state: State<'_, Arc<AppState>>,
|
|
connection_id: String,
|
|
database: String,
|
|
collection: String,
|
|
doc_json: String,
|
|
) -> Result<String, String> {
|
|
dbx_core::mongo_ops::mongo_insert_document_core(&state, &connection_id, &database, &collection, &doc_json).await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn mongo_update_document(
|
|
state: State<'_, Arc<AppState>>,
|
|
connection_id: String,
|
|
database: String,
|
|
collection: String,
|
|
id: String,
|
|
doc_json: String,
|
|
) -> Result<u64, String> {
|
|
dbx_core::mongo_ops::mongo_update_document_core(&state, &connection_id, &database, &collection, &id, &doc_json)
|
|
.await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn mongo_delete_document(
|
|
state: State<'_, Arc<AppState>>,
|
|
connection_id: String,
|
|
database: String,
|
|
collection: String,
|
|
id: String,
|
|
) -> Result<u64, String> {
|
|
dbx_core::mongo_ops::mongo_delete_document_core(&state, &connection_id, &database, &collection, &id).await
|
|
}
|