Skip to main content

upsert_settings

Function upsert_settings 

Source
pub(crate) async fn upsert_settings(
    client: &(impl GenericClient + Sync),
    pairs: &[(&str, String)],
) -> Result<(), AppError>
Expand description

一条语句写入(或覆盖)多个 settings 键,同时刷新 updated_at。

单条 SQL 在 PostgreSQL 中天然原子:要么全部生效、要么全部不生效, 避免逐键 upsert 中途失败导致「报错但部分配置已落库」,也不必开事务。 同一组配置的多个键必须走这里,而不是循环调用 upsert_setting。