findAndCountAll1 [JS] sequelize findAndCountAll 의 활용성 보통 findAll 로 찾아와서 그것에 대한 length 를 구해가지고 총 개수 값을 찾는 경우가 있는데요 만약 findAll을 하는데 pagination 때문에 limit 가 걸려있으면 그 만큼의 개수를 가져올 수 밖에 없어서 limit가 최대 개수가 되는데 이때도, 총 개수를 가져오고 싶다면 findAndCounAll 을 쓰면 됩니다. const db = require('../../모델 위치'); const a = await db.table_name.findAndCountAll({limit: 50}); console.log(a.rows.length) // 가져온 개수 50 console.log(a.rows.count.length) // table 에 들어있는 총 개수 findAndCountAll 로 .. 2023. 10. 31. 이전 1 다음