我的文档库

多根目录侧边栏

flex-layout

  • Getting Started

  • Guides

  • Reference

typed-rx-http

  • Getting Started

  • Guides

  • Reference

global-rx-state

  • Getting Started

  • Guides

  • Reference

webflux-fe-dev-assistant

reactive-mongo-dsl

批量与历史

区分适用保存生命周期的普通保存与批量插入/upsert、移除备份、历史快照的操作差异。


save / saveAll

save(entity)

如果没有 id,则使用 insertOne,如果有 id,则基于 _id 使用 replaceOne(..., upsert=true)

saveAll(...)

对每个实体执行 save(),因此适用 beforePersist/afterPersist 生命周期钩子。

选择批量 API

saveAllBulk

基于 insertMany 的批量插入。不是更新现有 id 的 API。

saveAllBulkUpsert

如果实体 id 不存在则插入,存在则执行 _id 过滤 + $set + upsert。

saveAllBulkUpsertByKey

基于业务复合键进行 upsert。如果任一键缺失,则该实体视为插入。

java
实体删除和移除备份
java

backup을 활성화하면 <sourceCollection>_remove collection을 사용합니다. delete와 backup을 하나의 원자 작업으로 묶어야 한다면 호출 측에서 getTxJob(...) transaction 범위를 잡습니다.

历史快照
java

createHistory는 현재 MongoExecutionContext.write(...) 결과를 deep copy하고 _id를 제거한 뒤 <sourceCollection>_history 또는 지정한 prefix collection에 insert합니다. history write도 save lifecycle hook을 호출하지 않습니다.

© 2026 Byeolnaerim. 保留所有权利.介绍隐私政策