Microsoft-community / Dotsimus-TS

1 stars 1 forks source link

New database engine/library suggestion #9

Open lost-in-action opened 3 years ago

lost-in-action commented 3 years ago

Should we use an alternative to mongodb/mongoose? MongoDB is mostly suitable if you don't know what the JSON object contains, Mongooses fixes that, but I believe it's better to use a DB that avoid the use of "non-typed" data, also, MongoDB is known to be slow overall.

Maybe PostgreSQL: since the data is structured and schemas aren't going to be changed, I believe using a relational database engine is best for the use case of this project, it scales well, also uses less memory/storage compared to MongoDB, and faster performance. It should work well in the long-term if the user base ever grow.

For libraries, here are some suggestions

The first one is an ORM where you define an universal database, then it generates all the code/classes around it, it's great and it's quite fast to learn, but it has the disadvantage of designing everything around one global schema, meaning it's not very suitable for modularity (a new plugin that stores data would mean a new entry in the global schema). The second one is would be nice for a plugin system, it can load models in a specific folder automatically and map them to tables. It's also a standard in TypeScript and it would make more sense if this project use TypeORM. I didn't put Sequelize, it isn't typescript

I personally like PostgreSQL and TypeORM for the use case of this project, but feel free to suggest something else that could be better.

dongle-the-gadget commented 3 years ago

IIRC MongoDB was chosen for original Dotsimus because Jaska had experience with it. Also this project doesn't quite have a clear path ahead, which makes development harder.

itsWindows11 commented 3 years ago

What if we use other NoSQL databases like firebase, or what about redis?

lavgup commented 3 years ago

Definitely recommend against using Firebase for Discord bots.

My personal pick is PostgreSQL (DB system doesn't matter too much for a simple bot) + Prisma. Prisma handles migrations really well - there's a central schema file (with models such as WatchMessage), and then on schema change Prisma modifies the SQL behind the scenes. As the schema file is generated at compile time, strong typing is available with TypeScript, and Prisma has the added benefit of actually having good documentation (something other ORMs like TypeORM, Mongoose and Sequelize don't really have).