I'm trying to use the realtime capabilities and it...
# javascript
r
I'm trying to use the realtime capabilities and it won't work for one of my tables. For one table its working just fine, for the other one I'm getting no events back. The UI shows both are toggled on, I am not using RLS.
I manually created both tables via SQL
g
Can you show your non-working subscribe. Any uppercase involved in table name/columns? Toggle the table off and on in replication.
r
just a single subscribe
Copy code
ts
client.connect();

client.onOpen(() => console.log("Socket opened."));
client.onClose(() => console.log("Socket closed."));
client.onError((e) => console.log("Socket error", e.message));

// Listen to events on a table, using the format `realtime:{SCHEMA}:{TABLE}`
var databaseChanges = client.channel("realtime:*");
databaseChanges.on("*", (e) => console.log(`${e.table}:${e.type}`));
databaseChanges.on("INSERT", (e) => console.log(e));
databaseChanges.on("UPDATE", (e) => console.log(e.table));
databaseChanges.on("DELETE", (e) => console.log(e));
databaseChanges.subscribe();

async function gracefulExit() {
  console.log("Stopping...");
  await client.disconnect();
}

process.on("SIGINT", gracefulExit);
process.on("SIGTERM", gracefulExit);
g
what are e.type and e.table?
r
type is update/insert/delete
table is the table name
g
So that is listening to all schemas and tables unless I'm missing something ("realtime:*"). What is your other channel set to? Also normally if you do .on with a * you don't need the other handlers. LOL I can't get an asterisk in the text
r
This was just copied and pasted from the https://github.com/supabase/realtime-js repo to see if I could get it to work
I plan on optimizing it once I prove moving to supabase will give me the realtime benefits I want
explicitly listening to the missing table isn't doing anything either
Copy code
ts
var flipChanges = client.channel("realtime:public:Flip");
flipChanges.on("*", (e) => console.log(`${e.table}:${e.type}`));
flipChanges.subscribe();
g
There is the cap thing I asked about in the beginning... Is your working table capped?
r
what do you mean about cap?
g
Flip
r
yeah the working one is
Profile
I can blow it away and recreate as lowercase if you think it will help
g
OK, realtime has had some issues with Prisma and capitals. If it worked for one should be OK , I think it was mainly a Prisma thing.
But postgres life is much simpler with lower case tables and columns. They will bite you at some point with caps.
r
I am using prisma, but I didn't have it run the SQL, it generated the sql and I manually ran it
g
That could be the issue if you used their SQL exactly. Let me grab a discord link.
r
looking through that thread I may have the same situation, making a few tweaks. Will report back
awesome! its working 🎉 It seems to be the prisma quoted enum types (I also adjusted everything to be all lowercase)