feat(mongo): preserve BSON types when cloning and saving documents

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-10 23:02:37 +08:00
1 parent cc7112b240
commit a5ce8510e7
12 files changed
+239 -36

No files matched your search

+22 -9
View File
@@ -105,17 +105,30 @@ pub async fn document_insert_document(
collection: String,
doc_json: String,
routing: Option<String>,
preserve_bson_types: Option<bool>,
) -> Result<String, String> {
ensure_connection_writable(&state, &connection_id, "Insert").await?;
dbx_core::document_ops::insert_document_core(
&state,
&connection_id,
&database,
&collection,
&doc_json,
routing.as_deref(),
)
.await
if preserve_bson_types.unwrap_or(false) {
dbx_core::document_ops::insert_document_preserving_bson_types_core(
&state,
&connection_id,
&database,
&collection,
&doc_json,
routing.as_deref(),
)
.await
} else {
dbx_core::document_ops::insert_document_core(
&state,
&connection_id,
&database,
&collection,
&doc_json,
routing.as_deref(),
)
.await
}
}
#[tauri::command]
+1
View File
@@ -430,6 +430,7 @@ pub async fn mongo_insert_document(
collection,
doc_json,
routing,
None,
)
.await
}