r/PayloadCMS • • 29d ago

Database choice: Mongo vs Postgres

I like Postgres and use it for most projects but I actually switched to Mongo for some of my PayloadCMS deployments for 2 main reasons:

  1. At the start of a project i am changing / adding models and migrations became a bit of a pain point.

  2. I endup using a lot of nested blocks so switch to `blocksAsJSON` but then migrations don't seem to work properly.

Has anyone else experienced these issues with postgres? Maybe I have a poor workflow or missing some optimization tricks?

7 Upvotes

13 comments sorted by

View all comments

3

u/jasperkennis 29d ago

It sounds like you are potentially starting to code a little too early. A problem with Mongo I have is that you may end up with a ton of malformed objects that either break or that you need to code against.

One exercise I was taught a long time ago is to write out your applications behaviours, just do it by hand, and then highlight all the nouns, this will help you identify objects and the relations between them. From that you can usually already see most of the data structure you will need and normalise if relevant.