Is storing data in a file (data.json) a good idea?


#1

I want to store JSON-objects in a data.json file (which is a JSON-array) and get this data by usind the fs module. So my question is if this is a good idea or should i go for using a database (I’m not sure if this is too “heavy” for a small application) ?

Thanks:)


#2

That’s for you to decide. Databases are more secure, but they also take more work (unless you already know everything about a database, you’re going to need to learn how to interact with it). Storing data in plain text also allows users to view or edit it directly, which could be an advantage or a disadvantage depending on your use case.

If you’re honestly not sure, it’s most likely easier to transition from writing to .json files to writing to a database than transitioning between unlike databases, so starting with file-saving could be a good measure to test your logic with output you can easily see and then transition to a database if you desire.


#3

thanks for your answer :slight_smile: yeah I’m not really sure what to use, because I don’t need any queries and so on, I always need all of my data (all the objects in the JSON-array) for my purposes