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

+21
View File
@@ -524,6 +524,27 @@ pub async fn insert_document_core(
}
}
pub async fn insert_document_preserving_bson_types_core(
state: &AppState,
connection_id: &str,
database: &str,
collection: &str,
doc_json: &str,
routing: Option<&str>,
) -> Result<String, String> {
ensure_document_pool(state, connection_id).await?;
let connections = state.connections.read().await;
match connections.get(connection_id).ok_or("Not found")? {
PoolKind::MongoDb(client) => {
mongo_driver::insert_document_extended_json(client, database, collection, doc_json).await
}
_ => {
drop(connections);
insert_document_core(state, connection_id, database, collection, doc_json, routing).await
}
}
}
pub async fn update_document_core(
state: &AppState,
connection_id: &str,