DEV Community

anst84
anst84

Posted on

Help! Project design tips - nextjs mongodb

I'm learning nextjs to build a web application. The data resides in a mongodb database. I have limited experience in nextjs so far, but as I understand it there are several methods to fetch and work with data.

**What I want to achieve:

  • The user should be able to apply multiple filters on the data to narrow the scope.
  • The user should be able to select amongst the filtered data and save records to personal list

**Notes:

  • Database has 6000 records. Records will keep growing by 500 records per year.
  • The user will work with the entire data scope several times to add record to their personal list.

**Solution ideas:

  • I foresee a form with multiple filters; checkboxes, sliders, drop-downs. Either the data is filtered in "real-time" or the user could hit a "apply filter button".
  • Ones the filtered data is shown a button is also shown together with each record from the db. Pushing the button would add that record to a separate list.

**Questions:

  • What is the best approach to fetch and work with the data? Should I get all the data from mongodb (unfiltered) and apply filters later? Or should I send the filters in the mongodb query?
  • Should I use getStaticProps, getServerSideProps or route the request to /pages/api to query mongdodb and return data?
  • Should I use MongoDB Atlas Search instead to filter/search the data?

Thanksful for any advice!

Top comments (0)