Friday 14 April 2017

Looking to make the switch from mongo + mongoose to postgres. Have some questions.

Like many new devs to node every course or tutorial I ever went through used mongo + mongoose. They've served me well so far because of the ease of use and flexibility of the schema but after doing more and more research I can't help but feel like I'm always using the wrong tool for the job. Pretty much all of my apps end up having relational data and I feel like I need to switch to a relational db asap. I realize there are tradeoffs for both but I feel like I've been forcing mongo to act as a relational db, when I could just be using a relational db in the first place.That being said, I've been doing research on both basic SQL and the current node tools available for interacting with SQL db's. I don't have much experience at all with fundamental SQL concepts so I'll probably go through a basic SQL course on Pluralsight. They also have a course on there for using Knex with Postgres which looks promising.I've found some good knex + postgres tutorials as well:http://ift.tt/2ouyKvC still have some questions that I was hoping you guys could offer some help with:I've been using some great mongoose features like validation for my models, pre-save / post-save hooks, and being able to call populate to populate a model's relationships. What is this like in Postgres / Knex? Anything missing or any tradeoffs?Am I correct that Knex is one of the most popular node libs for using Postgres? I've also seen mentions of Bookshelf, pg-promise, etc. but not sure what their current standings are. I'm basically looking for ease of use, power, and flexibility. Also promise based helps I'd like to avoid callbacks.Are there any cool things that you can do with Postgres and any libs that I should know about? I've heard people say Knex is easy to do unit tests with.Any problems or tradeoffs I should be aware of when making the switch? I've heard people say that Postgres can be harder to work with because of the need for migrations but don't have a ton of database experience so I need to look into some of this stuff.I've been building REST API's backed by mongoose, and there are some libs that will automatically create endpoints based on your mongoose collections, create a query object from your query string, etc. Are there any tools like this for Postgres?I'm planning on starting the switch this weekend so any help is greatly appreciated thanks!

Submitted April 14, 2017 at 05:08PM by m9js

No comments:

Post a Comment