๋ฐ˜์‘ํ˜•

์Šคํ”„๋ง๋ถ€ํŠธ 2

[Springboot] JPA์™€ pageable ํ™œ์šฉํ•œ sort ์ •๋ ฌ ๊ตฌํ˜„ ๋ฐฉ๋ฒ•

Intro์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” spring boot ์—์„œ JPA์™€ pageable ํ™œ์šฉํ•œ sort ์ •๋ ฌ ๊ตฌํ˜„ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. user ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ์ง„ํ–‰ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.  1. User ์—”ํ‹ฐํ‹ฐ ์ •์˜ User ์—”ํ‹ฐํ‹ฐ์—๋Š” id, name, email, createdDate ๋“ฑ์˜ ํ•„๋“œ๊ฐ€ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.@Entitydata class User( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val id: Long, val name: String, val email: String, @CreatedDate val createdDate: LocalDateTime) 2. UserReposit..

[SpringBoot] kotlin + SpringBoot + mongodb MongoRepository์—์„œ limit ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

Intro ์•ˆ๋…•ํ•˜์„ธ์š”. ์ด๋ฒˆ์‹œ๊ฐ„์—๋Š” ์Šคํ”„๋ง๋ถ€ํŠธ + mongodb MongoRepository์—์„œ limit ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. How to solve the problem ์•„๋ž˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด limit() ๋ฉ”์„œ๋“œ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์›ํ•˜๋Š” count ๋งŒํผ ์กฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. suspend fun getRecentData(createAt: Instant): List? { val query = Query() query.with( Sort.by(Sort.Direction.DESC, "createAt") ) query.limit(3) return metaHotMongoTemplate.find(query, SomeDTO::class.java, collectionName).collectList() .awa..

๋ฐ˜์‘ํ˜•