JavaScript Pagination in ~10 Minutes (Super EASY!!)

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024

Комментарии • 37

  • @soniablanche5672
    @soniablanche5672 Год назад +7

    skip/limit is pretty bad if you have a lot of rows. The database is actually iterating through all the items until it reaches the last item to skip. It's better to have some sort of index to use as a reference and fetch only the rows that have an index bigger than the reference index + limit

    • @marcoio8742
      @marcoio8742 Год назад +1

      Totally agree with you. Especially, nowadays with db that charge per usage like PlanetScale where you are billed per row read and written. Going up with the items, you end up reading a 1000 rows to then return 100 (that's a weird way SQL works honestly). Personally, I am using a method that I read somewhere which is working pretty nicely. You keep the limit to decide the size of the page, and then you receive the last id and when you fetch you use that as a start so you never read more than the number of rows you actually need

    • @JamesQQuick
      @JamesQQuick  Год назад +2

      Great point. It goes beyond the basics as covered in this video, but something worth calling out

    • @charlesscholton5252
      @charlesscholton5252 5 месяцев назад

      ​@@JamesQQuickI think the introduction of these advanced concepts early on to people will help them understand how important it is. I know I had to learn the hard way from following simple examples that kept me in the dark. It is a very frustrating experience for people to go through.

  • @melodium10
    @melodium10 Год назад +3

    The perfect explanation doesn't exi-
    but i thought that pagination is something where there are buttons 1, 2, 3 til the end and u click one of them and go to a page. never thought it was a single page thing too

    • @JamesQQuick
      @JamesQQuick  Год назад +2

      Pagination takes several different forms all with different use cases!

  • @CreativeTutorialsWeb
    @CreativeTutorialsWeb Год назад

    Always always always love your content James.
    Great work

    • @JamesQQuick
      @JamesQQuick  Год назад

      Thanks so much. really appreciate it :)

  • @Joe-SoftwareEngineer
    @Joe-SoftwareEngineer Год назад +6

    For the 1st kind of pagination that you mentioned, why not just pass the page number instead of the skip and calculate the skip server-side?

    • @JamesQQuick
      @JamesQQuick  Год назад +1

      It gives more flexibility to the frontend if the backend accepts both. Different apps may decide to display more/less items at a time. BUT using page number could definitely work!

  • @codegenesis2130
    @codegenesis2130 7 месяцев назад

    what is the vs code theme you are using?? please mention

  • @rajajunaidf
    @rajajunaidf Год назад +1

    Which VS Code theme are you using?

    • @JamesQQuick
      @JamesQQuick  Год назад +1

      This is my own theme - James Q Quick :)

    • @rajajunaidf
      @rajajunaidf Год назад

      That's Cool 🔥🔥🔥@@JamesQQuick

  • @HowManyShrimps-g7z
    @HowManyShrimps-g7z Год назад +1

    James, how much money Astro pays for your ad?

    • @JamesQQuick
      @JamesQQuick  Год назад

      None at all :) Thanks for clarifying that!

  • @la009895
    @la009895 Год назад

    For your Astro course, if you include how to deploy it to prod. Aka the web, I will buy it.
    I can get projects to run locally but as soon as it’s time to deploy I get lost.

    • @JamesQQuick
      @JamesQQuick  Год назад

      Definitely will include publishing to prod!

  • @simoid6246
    @simoid6246 5 месяцев назад

    but what if the url not have limit and skip query

  • @gliderguld
    @gliderguld Год назад

    How about cursorbased 0:44 pagination? And 'infinitive' data like dates.

  • @defaultname5607
    @defaultname5607 5 месяцев назад

    c'est pas plus facile getjson => create tab => read 10 first elements ?

  • @maxzapom
    @maxzapom 2 месяца назад

    This was very interesting thanks

  • @gioba4912
    @gioba4912 Год назад +1

    With was an awesome in a myriads of ways.
    - Presentation
    - clarity
    - pace
    - etc!
    Thank you!

  • @AndreSpecht
    @AndreSpecht Год назад

    Amazing. Do you have a tutorial for a blog with React and Firebase (or other DB)?

  • @derekbaker_
    @derekbaker_ Год назад +1

    This was perfect. Thank you

  • @PJlikePajamas
    @PJlikePajamas Год назад

    Love it! I’ll be looking forward to learning more about Astro in September!🤘🤘

    • @JamesQQuick
      @JamesQQuick  Год назад +1

      YAYYY!! It's getting close!

    • @PJlikePajamas
      @PJlikePajamas Год назад

      @@JamesQQuick I’ve been reading through the docs today so I’m at least somewhat familiar. Looks awesome, can’t wait to see it in action!

  • @蹦太君-o4d
    @蹦太君-o4d Год назад

    thanks >

  • @89tain
    @89tain Год назад

    This is really nice man

  • @jasonwelsh417
    @jasonwelsh417 11 месяцев назад

    You can tell this guy has never worked on a production database before

    • @JamesQQuick
      @JamesQQuick  10 месяцев назад

      Lol why is that?

    • @jasonwelsh417
      @jasonwelsh417 10 месяцев назад +1

      @@JamesQQuick Your example would have the database iterating until the last row instead of utilizing an index. If you have a large database this is a bad idea.

    • @charlesscholton5252
      @charlesscholton5252 5 месяцев назад +1

      ​@@jasonwelsh417 sshhh.. you are revealing too much arcane secret knowledge. I make jokes about how much of these things work great until the database grows or when encountering and dealing with large amounts of data.