Save Javascript Objects to Database

Hey guys i’m new to this so i need some information about it.

So i made a project that i end up with an array of objects. And i want to “save” those objects, so the next time that i open the web page i can see those same objects there.
Basically i need to store my objects in a databse.

1) What is a the best approach to achieve this? (and why)
2) What is the best practise?

Here is the sequence I would take, starting from simplest to hardest. These technologies are good because they are well-documented and there are plenty of blogs and videos showing how to use them.

I would start with LocalStorage. This will save it on the user’s computer and remain available unless they delete it.

Once you’ve got that down, maybe use Firebase. This is a Google product that you can use for free.

Then you should probably learn how to use MongoDB.

okay, and how do i learn which one is better for my project? what is the difference? local storage is stored locally i get that. But how do i choose between the others?

It depends on requirements. What kind of data do you have? Which of the CRUD operations will be used the most? Who is going to host the db? What db do you already know? What access/write speeds are required? Sharding? etc., etc.

P.S. It sounds like an interview question to test your system design skills :slight_smile:

okay so i made a project usings puppeteer(HTML scraping) in which a user gives his username/password and it logs in and gets the data of the people he follows/are following him like their name and their picture. And i want to store those objects in a database. What is the best to use in this examble? Firebase or Mongodb? also why not mysql?

I once asked an architect why they chose SQL database for the project and the answer was “Because we already knew it”.

But to answer your question, I personally would chose Firebase for PoC/demo project (because I’m too lazy to set up all that mongo stuff).

My philosophy would be to learn them all and during that process, you will come to find out what is best for you. Knowing a little bit about each of these technologies would be better than committing to one too early. Just my opinion…