Repository navigation
Closed
Description
This is how I use createElectricCollection and useLiveQuery :
const taskDemandCollection = createElectricCollection<TaskDemand>({
id: "task_demands",
streamOptions: {
url: `http://localhost:3000/task_demands`,
headers: {
Authorization: `Bearer ${token}`,
},
},
params: {
table: "task_demands",
},
primaryKey: ["id"],
schema: TaskDemandSchema,
});
const { data: taskDemands } = useLiveQuery((query) =>
query
.from({ taskDemandCollection })
.select("@id", "@demand", "@status")
.keyBy("@id")
);This is the subsequent HTTP response from http://localhost:3000/task_demands?handle=111322364-1749222878597402&offset=0_0 :
[
{
"value": {
"demand": "Buy a new couch",
"id": "1",
"notify_slack": "t",
"status": "pending",
"user_id": "1"
},
"key": "\"public\".\"task_demands\"/\"1\"",
"headers": {
"last": true,
"relation": [
"public",
"task_demands"
],
"operation": "insert",
"lsn": "36341840",
"op_position": 0,
"txids": [
858
]
}
},
{
"value": {
"id": "1",
"status": "researching"
},
"key": "\"public\".\"task_demands\"/\"1\"",
"headers": {
"last": true,
"relation": [
"public",
"task_demands"
],
"operation": "update",
"lsn": "36350304",
"op_position": 0,
"txids": [
868
]
}
},
{
"value": {
"id": "1",
"status": "completed"
},
"key": "\"public\".\"task_demands\"/\"1\"",
"headers": {
"last": true,
"relation": [
"public",
"task_demands"
],
"operation": "update",
"lsn": "36638528",
"op_position": 0,
"txids": [
889
]
}
},
{
"headers": {
"control": "up-to-date",
"global_last_seen_lsn": "36638528"
}
}
]whole response with headers are :
[{"value":{"demand":"Buy a new couch","id":"1","notify_slack":"t","status":"pending","user_id":"1"},"key":"\"public\".\"task_demands\"/\"1\"","headers":{"last":true,"relation":["public","task_demands"],"operation":"insert","lsn":"36341840","op_position":0,"txids":[858]}},{"value":{"id":"1","status":"researching"},"key":"\"public\".\"task_demands\"/\"1\"","headers":{"last":true,"relation":["public","task_demands"],"operation":"update","lsn":"36350304","op_position":0,"txids":[868]}},{"value":{"id":"1","status":"completed"},"key":"\"public\".\"task_demands\"/\"1\"","headers":{"last":true,"relation":["public","task_demands"],"operation":"update","lsn":"36638528","op_position":0,"txids":[889]}},{"headers":{"control":"up-to-date","global_last_seen_lsn":"36638528"}}]
But a Uncaught TypeError: Do not know how to serialize a BigInt error is triggered in key-by.ts, line 54.
row is {id: 1n, demand: 'Buy a new couch', status: 'completed'}
We see that id is a BigInt.
It it because id type is int8
Metadata
Metadata
Assignees
Labels
No labels
Activity
samwillis commentedon Jun 6, 2025
Ah, thanks. This is due to the hashing inside the the D2TS query engine. I've filed an issue to remind me over there: neondatabase/electric-d2ts#55
KyleAMathews commentedon Jun 6, 2025
@samwillis key-by.ts is in this repo right?
I added a pr for that #143
KyleAMathews commentedon Jul 23, 2025
This is fixed now