
Show HN: Realtime Slack clone using Postgres - kiwicopple
https://github.com/supabase/supabase/blob/master/examples/slack-clone-basic/README.md
======
ampdepolymerase
How do you deal with conflicts in PostgreSQL due to sync issues?

~~~
kiwicopple
I assume you’re talking about conflicts from offline -> online?

This example is quite simple - it doesn’t work offline so it doesn’t have any
risk of conflicts beyond the usual things a developer would face (2 ‘channels’
with the same name). This obviously sacrifices functionality for simplicity.

We plan to work on client/server conflict resolution at some stage but it’s a
fairly deep hole so we need to plan out the best strategy (or multiple
strategies?)

Let me know if I misinterpreted your question

~~~
ampdepolymerase
Firebase uses last write wins but they do have a backlog so the user can sync
up. There is also a transaction () function for manual conflict handling.
Perhaps you can automatically raise an exception in the event of conflicts.

[https://stackoverflow.com/questions/19975921/how-does-
fireba...](https://stackoverflow.com/questions/19975921/how-does-firebase-
deals-with-events-performed-while-offline)

A bit of feedback, the API looks fairly verbose compared to Firebase so a high
level wrapper would be nice. Though that could simply be a side effect of
Next.js being clunky.

~~~
kiwicopple
Amazing - thanks for the link. We've had a few people ask about sync now, so
something we'll start researching soon.

> A bit of feedback, the API looks fairly verbose compared to Firebase

Thanks for this feedback. I do hope that it's just Next.js cluttering up.
Here's a comparison without Next.js:

Realtime Firebase:

    
    
        db
        .collection("cities")
        .doc("SF")
        .onSnapshot(payload {
            console.log("Current data: ", payload.data())
        });
    

Realtime Supabase:

    
    
        supabase
         .from('cities')
         .eq('id', 'SF')
         .on('UPDATE', payload => {
            console.log("Current data: ", payload)
         })
         .subscribe()

