Spring int 值之间的数据 MongoRepository

Spring Data MongoRepository between for int values

有一个class比如(这是kotlin,但是代码很好理解):

@Repository
interface ScoresRepository : MongoRepository<Score, String> {
    fun countAllByScoreIsBetween(min: Int, max: Int): Int
}

@Document
data class Score(
    @Id var score: Int,
)

between inclusive还是exclusive?也就是说,如果我的分数是 1-10,我会调用: countAllByScoreIsBetween(3,6) 我会得到 4 还是 2?或者可能是其他东西 - 底部是包容性的而顶部是排他性的?

测试(testcontainers)显示:

@Autowired
lateinit var scoresRepository: ScoresRepository

@Test
fun test() {
    for (i in 1..10) {
        scoresRepository.save(Score(score = i))
    }

    val count = scoresRepository.countAllByScoreIsBetween(3, 6)

    assertThat(count).isEqualTo(2)
}

据我所知,这两个参数都不包括在内。也就是说,Between 表示值之间的所有内容,不包括值本身。