I've seen many similar questions, but nonecan address my particular inquiry:
I want to have my own JSON based database, similar to how MongoDB and firebase have BSON databases', and I figured the simplest way to do that is just to: store some JSON data in a file, load the file when the node.js application starts (into memory of the node.js server) and whenever I Make a search of some sort, just search through the JSON object loaded in the server using .find (if it sall in a big array) and .sort for Object.keys() etc., and then for every change, make a queue (maybe even on another thread) to store the data back to the file, so that 2 entires can't be stored at once (since they're mainly just accessing it in the JSON object stored in memory already, not reading from the file every time).
The problem: If its a huge database, wouldn't that crash the server for storing that much (like maybe 2GB) of JSON data in memory?
how does MongoDB and other nosql databases actually STORE the data? Do they have a separate file for each document / database, and only load into memory what they need? Is there some other way to store database tables / documents into files for later use (and still be able to (almost) instantly access nested JSON objects? Is BSON somehow different in that it can be accessed faster than JSON data? Do they also store the entire database into memory when its loaded?