by Kiro · 9y ago · 0 comments
if (player.hasSomeProp) {
doStuff(player);
}
With your suggestion I would have a table with 200 fields and would probably have to add a lot of related tables since some of the props are arrays, objects etc. I also would lose the ability to just load the player as is (player = documentFromDB).With "no-brainer" I mean it doesn't take any effort when developing since the representation of the player object in runtime is exactly the same as it's stored in the database.
There are also excellent out-of-the-box support for arrays, enums, custom types, and JS procedures if you so desire. All that comes with consistent syntax, great aggregation functions, JOINs; and all those 43 years of advancement mentioned in general.
Read the docs, you'll be amazed with what you're missing :)
General overview https://www.postgresql.org/docs/current/static/tutorial.html
JSON support specifically https://www.postgresql.org/docs/current/static/datatype-json...
If you just want things as JS objects, you could have a Player table with a column for playerID and a column for the JSON string.
I'm not saying you shouldn't use Mongo/NoSQL, I just think SQLite is an interesting potential choice. (e.g. https://sqlite.org/appfileformat.html)