Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
woole
Contributor
Contributor

Does anyone use JSON files as a database? Best practises? Or should I use a "real" database?

I've been using JSON files to store data since I began learning Node, but I'm now working on big projects so I need 0% chance of losing data.

I had a problem where Node crashed while writing to a file and I was left with half a JSON file, but I guess this can be solved by writing to a temp file first and then moving it to where the original file is.

I like how easy it is to just use JSON files as databases. I can very easily read data, amend it, and save it in one line each. No packages to install and learn how to use. I try to use no NPM packages where possible because I like learning how to do things myself and time isn't an issue and I'm the only one working on these projects.

I also read a comment by someone who makes directories for arrays and individual files for objects instead of using one single JSON file per table.

If someone could enlighten me on why JSON files might not be a good idea for production, or if there are some things I should know before doing this, that would be really helpful.

Labels (1)
  • Other

1 Reply
F_B
Creator III
Creator III

Hi @woole ,

as you’ve experienced, sudden crashes or interruptions during writes can lead to corrupted JSON files. Moreover, as your projects grow, managing multiple JSON files or directories can become cumbersome. A database system ensures better data integrity and scalability.

Have a nice day