petecoop / generator-express

An express generator for Yeoman, based on the express command line tool.
MIT License
814 stars 133 forks source link

Add support for pg-promise #162

Open nitetrik opened 8 years ago

nitetrik commented 8 years ago

Is it possible to replace the Node Postgres with PG-Promise?

petecoop commented 8 years ago

currently Postgres support is using Sequelize, but I'm open to adding other methods e.g Bookshelf #151.

I think as long as there is a default/preferred option highlighted so it doesn't cause information overload for people just wanting to get something up and running without having to research all the choices

nitetrik commented 8 years ago

Sounds good!

vitaly-t commented 8 years ago

@petecoop if you decide to do that, I will help you (I'm the author of pg-promise) ;)

petecoop commented 8 years ago

I think the main difference is that at the moment I'm using ORM's for the models/DB integration. pg-promise looks like something you would run raw queries with, and use to build an ORM on top.

Of course I'm happy to find a way to build some templates that use raw queries rather than an ORM if people want that, so maybe the options that are presented once selecting Postgres are something like:

Which database library would you like to use?
- Sequelize (ORM)
- Bookshelf (ORM)
- pg-promise (Raw queries)

What do you think @nitetrik ?

nitetrik commented 8 years ago

@petecoop I think that would be great, as i use raw queries for some things. Its good to have choices.

petecoop commented 8 years ago

What do you use for the "M" in MVC @nitetrik ? Do you create a plain javascript object and put queries in there? or not bother with it at all?

vitaly-t commented 8 years ago

If you guys need an idea of what an app template with pg-promise might look like, have a look at pg-promise-demo.

pg-promise looks like something you would run raw queries with, and use to build an ORM on top.

@petecoop at the very core, yes, you are right. But it also features the best query formatting you can find in a library that's ultimately customizable. Custom Type Formatting, for example, allows developers extend formatting any way they like. And event extend allows extending the protocol with your own repositories - see the demo.

Anyway, the point being, you wouldn't want to use pg-promise to implement an ORM on top of it, there is really no need, it is very self-sufficient. Not to mention it has the best support for transactions you can find, and that's a very high-level stuff, not just raw query formatting. See Tasks and Transactions.

nitetrik commented 8 years ago

I think having choice on whether you want to use ORM like Sequelize, Bookshelf, Waterline, Caminte JS, etc or RAW queries. Cause for certain things raw queries are what all you need.