PgREST: Node.js in the Database, compatible with MongoLab and Firebase API
pgre.st
pgre.st
Is that what we're calling this whole 30 lines of javascript, mongo and redis behind the WAN, dynamic language runtime inside the DB era?
Cool.
EDIT: saying that, some kind of featureful document store implementation inside postgres seems inevitable. Isn't that all going to be hstore-based though, what with the new stuff coming in 9.4? I thought the json type was meant to be kind of a stopgap until the full hstore functionality is finished, ie. nesting?
It's worth noticing, that MongoDB index is very "narrow" index, while hstore's indexes could speedup more queries.
====
Well, wow. This is 6-12 months away, and really exciting.
PgREST also comes with a shim JSON type for Postgres version 9.1 and earlier, so the column type implementation is mostly hidden from the user.
I'd recommend reading the recent post https://news.ycombinator.com/item?id=6813937
A secondary motivation is using two familiar APIs — MongoLab and Firebase — to access existing PostgreSQL databases.
(We're using this in production at Socialtext and g0v.tw.)
Is there really a significant population of developers now to whom these are more familiar query languages than SQL?
Honest question.
We don't generally send SQL over the wire, though. :-)
That is to say, front-end programmers usually work with a middleware (or backend-as-a-service) layer that translates REST/JS API requests into backend storage, and PgREST simply implements this layer with Postgres itself.
EDIT: I did some research: there is no difference. It's just plain ol' rails-style REST. This project is basically taking your thin sinatra/express/flask API layer and pushing it into the database itself, for reasons I am as yet unable to ascertain.
The main difference is that back-end models, validation rules, triggers and views are coded in DB level via stored procedures written in Node.js-compatible modules, so it's enforced for both SQL- and HTTP-speaking clients.
As you pointed out, this is simply an instant JSON-over-REST API server on top of existing Pg databases, and is not intended to replace the need for traditional frameworks with server-side templating.
EDIT: how easy do you think it would be to do the authentication etc outside, at the level of the nginx proxy?
For authorization (authz) it's IMHO a bit better to handle it in the DB level, similar with Firebase's ACL lists.
Buzzwords mean whatever the fuck you want them to mean.
PgREST was originally designed for a large, in-production Postgres app (i.e. Socialtext), so we can get all the model, validation, view & trigger code in one place, getting the benefits of CouchApps while maintaining the underlying data layer.
For new projects, the main difference is likely familiarity with the toolchain (npm+Pg vs Kanso+CouchDB).
Back in the day, I thought Couchapps and Kanso + CouchDB were great and I hoped they would lead an entire new breed of web applications.
Thank you for making it happen!
Looking forward to seeing what else the team comes up with since I've already replaced my MUNI estimation time app with the Firebase SF Muni app :-D
Firebase++ for an extremely well-thought-out API, though!