3 ms·
Have used both. Depends how you use them. If you use jsonb of postgres to just dump things you don't query on, it's fine. If you try to cheat and dump your m
by silisili 5y ago
Have used both. Depends how you use them.
If you use jsonb of postgres to just dump things you don't query on, it's fine. If you try to cheat and dump your mongo schema into a jsonb field, you're gonna have a bad time.
JSON queries in postgres are, IMO, extremely nonobvious. It seems like any time we wanted to run some rather simple report that involved json fields, some poor dev had to spend ten or more minutes figuring out the correct syntax to do so. Mongo is an absolute breeze in comparison.
Person opinion? JSON doesn't belong in the db, make a proper schema. If you don't want to do that, or don't like or want to learn SQL, just use Mongo or some equivalent.
- patrickthebold 5y agoJust a side note: If you don't need to query your json, you can use a text field instead of jsonb.
- silisili 5y agoTrue, but the json types should at least verify it's valid json, which may be useful.
- patrickthebold 5y agogood point.
- plasma 5y agoMost recent pg releases use the -> operator to access json fields now, in case you didn’t know about this syntax improvement.
- silisili 5y agoYeah, thanks. It's mostly all the built in functions and converting you have to do to pull the data back out I was referring to. It's not impossible, but the result always looks like something that makes you not feel bad for having looked it up (because who would remember that). TBH, about half the time, I cheat and cast the whole thing to text and just do a string search on the blob.