[모각글] 2023-12-05 #7
cheese10yun
announced in
Announcements
Replies: 3 comments
-
Mongo Bulk Update override fun updateInBulk() {
val listOf = listOf(
{ Query(where("_id").`is`(1)) } to { Update().set("rule_id", 24) },
{ Query(where("_id").`is`(4)) } to { Update().set("rule_id", 21) },
{ Query(where("_id").`is`(5)) } to { Update().set("rule_id", 21) },
{ Query(where("_id").`is`(2)) } to { Update().set("rule_id", 22) }
)
updateInBulk(listOf)
}
protected fun updateInBulk(
operations: List<Pair<() -> Query, () -> Update>> // Query와 Update 생성자를 위한 람다 리스트
): BulkWriteResult {
// BulkOperations 객체를 생성합니다.
val bulkOps = mongoTemplate.bulkOps(BulkOperations.BulkMode.UNORDERED, documentClass)
// 제공된 리스트를 반복하면서 bulk 연산에 각 update를 추가합니다.
operations.forEach { (queryCreator, updateCreator) ->
bulkOps.updateOne(queryCreator.invoke(), updateCreator.invoke())
}
// 모든 업데이트를 실행합니다.
return bulkOps.execute()
}
|
Beta Was this translation helpful? Give feedback.
0 replies
-
디지털 시그니처 관리 및 필터를 통한 검증 처리에 대해서 고민해보았습니다. |
Beta Was this translation helpful? Give feedback.
0 replies
-
앞으로 사내 문서 정리에 신경을 써볼까합니다. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
[모각글] 2023-12-05
Beta Was this translation helpful? Give feedback.
All reactions