package com.securityc4po.api.pentest

import org.springframework.data.mongodb.repository.DeleteQuery
import org.springframework.data.mongodb.repository.Query
import org.springframework.data.mongodb.repository.ReactiveMongoRepository
import org.springframework.stereotype.Repository
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono

@Repository
interface PentestRepository : ReactiveMongoRepository<PentestEntity, String> {

    @Query("{'data.projectId': ?0, 'data.category': ?1}")
    fun findPentestByProjectIdAndCategory(projectId: String, category: PentestCategory): Flux<PentestEntity>

    @Query("{'data._id' : ?0}")
    fun findPentestById(id: String): Mono<PentestEntity>

    @Query("{'data._id' :{\$in: ?0 }}")
    fun findPentestsByIds(id: List<String>): Flux<PentestEntity>

    @DeleteQuery("{'data._id' : ?0}")
    fun deletePentestById(id: String): Mono<Long>
}