Skip to content

Commit ee3b532

Browse files
Joel LeeJoel Lee
Joel Lee
authored and
Joel Lee
committed
Add transformers
1 parent 19f6e8e commit ee3b532

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: supabase_py/lib/realtime_client.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from typing import Any, Callable
22

33
from realtime_py.connection import Socket
4+
from realtime_py.transformers import convert_change_data
45

56

67
class SupabaseRealtimeClient:
7-
def __init__(self, socket, schema, table_name):
8+
def __init__(self, socket: Type[Socket], schema: str, table_name: str):
89
topic = (
910
f"realtime:{schema}"
1011
if table_name == "*"
@@ -14,11 +15,12 @@ def __init__(self, socket, schema, table_name):
1415

1516
def get_payload_records(self, payload: Any):
1617
records = {"new": {}, "old": {}}
17-
# TODO: Figure out how to create payload
18-
# if payload.type == "INSERT" or payload.type == "UPDATE":
19-
# records.new = Transformers.convertChangeData(payload.columns, payload.record)
20-
# if (payload.type === 'UPDATE' || payload.type === 'DELETE'):
21-
# records.old = Transformers.convertChangeData(payload.columns, payload.old_record)
18+
if payload.type == "INSERT" or payload.type == "UPDATE":
19+
records.new = payload.record
20+
convert_change_data(payload.columns, payload.record)
21+
if (payload.type === 'UPDATE' or payload.type === 'DELETE'):
22+
records.old = payload.record
23+
convert_change_data(payload.columns, payload.old_record)
2224
return records
2325

2426
def on(self, event, callback: Callable[..., Any]):

0 commit comments

Comments
 (0)