How I setup pagination in my Next.js app (with Drizzle ORM)

preview_player
Показать описание
Become a YT Members to get extra perks!

My Products

Useful Links
Рекомендации по теме
Комментарии
Автор

Keep going Cody! You will finish your starter kit sooner or later, but remember that you'll not be never 100% satisfied with your own product.
I'm also making something, I'm taking you as a reference, so keep going!
I'm learning a lot from you, ( zsa, structure...), and checking all your videos for the details that you share from time to time.

I bet you finish before I do

troneras-tv
Автор

About to use drizzle in a project very soon and your videos have been real helpful!

UnderCtrl
Автор

You have to put a limit on the page number, otherwise you'll have an open DoS vector on tables with many records. Because of how offsets work in SQL.

DmitryShpika
Автор

Nice video. A little improvement could be to run findMany and the count query in parallel with a Promise.all

miha
Автор

I didn't get how to setup total number of pages to display. I mean in order to know the last page (ex. 4) you would need to get all data from db, which is a big query. Or is there a drizzle method to get total number or records from single table which is optimized for that kind of scenario?

tsykin
Автор

It looks good, but how would you manage 2 paginated tables in one page? how would you structure the URL?

drenns
Автор

Could you cover what piece of the page is returned on next page load? I assume, it is not entire page html fetched on each next page? I normally would assume this is case where client side fetching would work better ux wise, wouldn't it?

omnizsk
Автор

Hey! Great vid. Do you think you could do an updated video on TDD for web applications specifically? Mainly unit testing. It seems complicated in this day and age :)

LeviCrider
Автор

Great video! Is there any way you'd recommend handling a list of elements? Like a conversation, I was thinking pagination isn't feasible for that type of rendering

michaels_offshore
Автор

I tried similiar approach, but the problem is the count operation actually takes longer than the data fetching for data that has > 100k rows. I found just takes all the data and filter client side works better. I'm open for recommendation

yudistiraashadi
Автор

Curious why you haven't used try catch in server actions. How do you handle errors in that case?

EditsByShobhit
Автор

Which vs code theme you are using in the video

anoopjha
Автор

Looks noice my dude, question: would moving the db call to find how many groups there are be best in a separate cached function? Might not be worth doing but if the no.of groups is u likely to change you can save some resources :)

joeyywill
Автор

Isn’t it doing multiple query db heavy as well as counting rows?

nikmat
Автор

what about
count: sql`COUNT(*) OVER () as count`.mapWith(Number)
it is faster and cleaner

nurbekizbassar
Автор

Can you do the same for infinite scrolling??

vanshchopra
Автор

This is also how I did it, although you don't really go into details it sounds mostly like the same thing. If your database is slow to respond and it takes several seconds for each query to get sent to the user, page switching will be very slow and they probably won't want to use it. Same with sorting and filtering data, unless it's all on one page and you don't need pagination, you will have a very slow app and a frustrating user experience.

ianc
Автор

Maybe it's a little bit better have another usecase that counts the number of groups, because now each time you move to another page the count is recalculated, unless you did this on purpose in case a group was added when navigating

yassine-sa
Автор

Not the best implementation but is okay.

whoman