🀔Where to filter the data – backend or frontend ?

Hey everyone,

In this article, let us discuss about a very important question regarding filtering the data that we get from the database or API. So the question is : 

Where exactly should we filter the data ? 

🀔 Backend … ? 

🀔 Frontend … ? 

We…


This content originally appeared on DEV Community and was authored by The Nerdy Dev

Hey everyone,

In this article, let us discuss about a very important question regarding filtering the data that we get from the database or API. So the question is : 

Where exactly should we filter the data ? 

🀔 Backend ... ? 

🀔 Frontend ... ? 

Well, the answer is : 

It depends. 

Let us discuss now : 

So if you have a a large amount of data, it is better to implement the filtering logic on the backend and let the database handle all the heavy lifting for us. Contrary to this, if you are dealing with less amount of data, you can do the filtering logic on the frontend.

In general, if you are working with a million recordset (as an example) and there are tons of users trying to access those records at the very same, then in such cases it does not make sense to send a million recordset to every user who is currently accessing the website. It simply does not make sense because it will simply bring your website down, so what we do in such cases is that we setup a record limit (kind of we send the data in batches) by using a features like database cursors. So kind of with the cursors in place, you can fetch the data in batches in some sort of pagination etc. Consider a big ecommerce website like Amazon, this is how they handle that amount of data in a nutshell.

For less amount of data, you could retrieve the data from the backend and then use the filtering logic on the frontend.

So this is it for this article. Thanks for reading.
Don't forget to leave a like if you loved the article. Also share it with your friends and colleagues.

Alt Text

PS - If you are looking to learn Web Development, I have curated a FREE course for you on my YouTube Channel, check the below article :

Looking to learn React.js with one Full Project, check this out :


This content originally appeared on DEV Community and was authored by The Nerdy Dev


Print Share Comment Cite Upload Translate Updates
APA

The Nerdy Dev | Sciencx (2021-11-10T06:11:46+00:00) 🀔Where to filter the data – backend or frontend ?. Retrieved from https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/

MLA
" » 🀔Where to filter the data – backend or frontend ?." The Nerdy Dev | Sciencx - Wednesday November 10, 2021, https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/
HARVARD
The Nerdy Dev | Sciencx Wednesday November 10, 2021 » 🀔Where to filter the data – backend or frontend ?., viewed ,<https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/>
VANCOUVER
The Nerdy Dev | Sciencx - » 🀔Where to filter the data – backend or frontend ?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/
CHICAGO
" » 🀔Where to filter the data – backend or frontend ?." The Nerdy Dev | Sciencx - Accessed . https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/
IEEE
" » 🀔Where to filter the data – backend or frontend ?." The Nerdy Dev | Sciencx [Online]. Available: https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/. [Accessed: ]
rf:citation
» 🀔Where to filter the data – backend or frontend ? | The Nerdy Dev | Sciencx | https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.