Skip to content

Commit

Permalink
repository: Delete by attribute instead of object
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Verma <[email protected]>
  • Loading branch information
shank03 committed Nov 1, 2023
1 parent 47ae05d commit cb7108b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,17 @@ class AdminRepository(
)

@Transactional
fun delete(admin: Admin): Mono<Void> = db.delete(admin).then()
fun delete(admin: Admin): Mono<Void> = db
.delete(
Query.query(
Criteria
.where(Admin::cid.name)
.`is`(admin.cid)
.and(
Criteria.where(Admin::uid.name).`is`(admin.uid),
),
),
Admin::class.java,
)
.then()
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ class MemberRepository(

@Transactional
fun delete(member: Member): Mono<Void> = exists(member)
.flatMap { if (it) db.delete(member) else Mono.just(member) }
.flatMap {
if (it) {
db.delete(
Query.query(
Criteria.where(Member::uid.name).`is`(member.uid)
.and(Criteria.where(Member::chid.name).`is`(member.chid)),
),
Member::class.java,
)
} else {
Mono.just(member)
}
}
.then()

@Transactional
Expand Down

0 comments on commit cb7108b

Please sign in to comment.