DEV Community

Cover image for Real time + Postgres = ?

Real time + Postgres = ?

Alex Barashkov on November 13, 2018

Real time updates are a part of almost every modern web and mobile application, with uses in everything from banking apps to news feeds. There are ...
Collapse
 
imthedeveloper profile image
ImTheDeveloper

Nice to see this!

I've been using the postgres notify method for a while now and setting up triggers all over my tables to output JSON to pub/sub messaging service. It worked really well and blew my mind a little bit to see live website updates without any screen refreshing once I had WS set up. However! as mentioned this was a painful and often manual process. I'll be giving Hasura a test as it would really help to make this painless from your explanation

Collapse
 
alex_barashkov profile image
Alex Barashkov

Yep. Did the same for a long time too, Postgres native notifications very reliable and work amazing, but I always wondered about the better solution, to prevent having extra dependencies and subscription logic in the microservices.

Collapse
 
imthedeveloper profile image
ImTheDeveloper

Another product I just came across:

debezium.io/

Streams into Kafka for db updates.

Collapse
 
mkhtradm01 profile image
Adamu Muktar • Edited

Any tips on how you do that? or code snippets, please?

Fortunately, I found Hasura Package for flutter in pub.dev

Collapse
 
imthedeveloper profile image
ImTheDeveloper • Edited

gist.github.com/colophonemes/9701b...

Good convo and examples here I followed.

Hasura as a product now comes with all of this too but you may have the case where you don't want to go that route, so these scripts help.

Thread Thread
 
mkhtradm01 profile image
Adamu Muktar

Thanks dear, I found Hasura Package for Flutter Developers

Collapse
 
rafaacioly profile image
Rafael Acioly

This is super nice!

Alex, in your project you use React (or any js framework) on frontend?
I was thinking in use Hasura but not with JS, and on Hasura site there nos no example with another language.

Collapse
 
alex_barashkov profile image
Alex Barashkov

We use React/Redux and graphql client to deal with Grapql. So actually you don't need to look at Hasura examples because Hasura runs for you standard Graphql server, so if you want to handle Graphql connection from the frontend and execute queries just use official guide of GraphQL.

Collapse
 
mkhtradm01 profile image
Adamu Muktar

I have been looking for a solution to use in our mobile Application developed with flutter and cloud Firestore.

We have pricing issues and our main data is on PostgreSQL which we want to use in our mobile app but no realtime feature. Will try this and see if it can work for me.

Collapse
 
ben profile image
Ben Halpern

This is really great. My issues with RethinkDB is that Iโ€™ve never worked on a project with great clarity of DB-layer needs early on, and choosing more exotic DBs ends up being a pain.

Iโ€™m sure in other contexts, you have a better idea of what you need early on. But in my cases it has made more sense to start with basic CRUD/polling and then add real-time layer as needed.

So with that in mind I like tools that interface with Postgres or my appโ€™s logic agnostically.

RethinkDB is still cool and probably a better option than when I was playing with it in a less mature state

Collapse
 
alex_barashkov profile image
Alex Barashkov

Unfortunately after the author of RethinkDB stopped maintaining it, not to much changes happen. Used it year ago, and still there were a lot of limitations about queries with real time updates option turned on. So finally I guess GraphQL + Hasura gives that ability of having proper client side access to the data which is stored in a mature database and old fashion database.

Collapse
 
rdewolff profile image
Rom

Nice, thanks for sharing. Did not know this library.