Realtime · Socket.IO
Database: collections & documents
Subscribe to collection/document/query rooms and listen for schema + row events.
Subscribe (object form — ack)
Emit:
json
{
"projectId": "6958511e8397f2dfa88090d8",
"collectionId": "64a1b2c3d4e5f6789012345"
}{
"projectId": "6958511e8397f2dfa88090d8",
"collectionId": "64a1b2c3d4e5f6789012345"
}Response: subscribed
json
{
"type": "collection",
"id": "64a1b2c3d4e5f6789012345",
"projectId": "6958511e8397f2dfa88090d8"
}{
"type": "collection",
"id": "64a1b2c3d4e5f6789012345",
"projectId": "6958511e8397f2dfa88090d8"
}Subscribe (string form — no ack)
javascript
socket.emit("subscribe:collection", "64a1b2c3d4e5f6789012345")socket.emit("subscribe:collection", "64a1b2c3d4e5f6789012345")Collection schema events (REST)
Event name pattern: db:<action> with underscores for collection lifecycle.
| Event | When |
|---|---|
db:collection_created | Collection created |
db:collection_updated | Collection/schema updated |
db:collection_deleted | Collection deleted |
Example db:collection_created:
json
{
"projectId": "6958511e8397f2dfa88090d8",
"collectionId": "64a1b2c3d4e5f6789012345",
"action": "collection_created",
"data": {
"_id": "64a1b2c3d4e5f6789012345",
"name": "Orders",
"slug": "orders",
"fields": [],
"project": "6958511e8397f2dfa88090d8"
},
"timestamp": "2026-03-18T10:00:00.000Z"
}{
"projectId": "6958511e8397f2dfa88090d8",
"collectionId": "64a1b2c3d4e5f6789012345",
"action": "collection_created",
"data": {
"_id": "64a1b2c3d4e5f6789012345",
"name": "Orders",
"slug": "orders",
"fields": [],
"project": "6958511e8397f2dfa88090d8"
},
"timestamp": "2026-03-18T10:00:00.000Z"
}Row CRUD events (Data API)
| Event | When |
|---|---|
db:create | Document created |
db:update | Document updated |
db:delete | Document deleted |
Example db:create:
json
{
"projectId": "6958511e8397f2dfa88090d8",
"collectionId": "64a1b2c3d4e5f6789012345",
"action": "create",
"data": { "_id": "64d...", "title": "Row 1", "createdAt": "..." },
"timestamp": "2026-03-18T10:00:00.000Z"
}{
"projectId": "6958511e8397f2dfa88090d8",
"collectionId": "64a1b2c3d4e5f6789012345",
"action": "create",
"data": { "_id": "64d...", "title": "Row 1", "createdAt": "..." },
"timestamp": "2026-03-18T10:00:00.000Z"
}Delivered to project:<projectId> and collection:<collectionId>.
Document room
javascript
socket.emit("subscribe:document", {
projectId: "6958511e8397f2dfa88090d8",
collectionId: "64a1b2c3d4e5f6789012345",
documentId: "64d1e2f3a4b5c67890123456",
})socket.emit("subscribe:document", {
projectId: "6958511e8397f2dfa88090d8",
collectionId: "64a1b2c3d4e5f6789012345",
documentId: "64d1e2f3a4b5c67890123456",
})Query room
javascript
socket.emit("subscribe:query", {
projectId: "6958511e8397f2dfa88090d8",
collectionId: "64a1b2c3d4e5f6789012345",
queryId: "dashboard-orders-active",
query: { status: "active" },
})socket.emit("subscribe:query", {
projectId: "6958511e8397f2dfa88090d8",
collectionId: "64a1b2c3d4e5f6789012345",
queryId: "dashboard-orders-active",
query: { status: "active" },
})Note
The server must emit to
query:<queryId> for filtered pushes — join is supported; wiring from the API is product-specific.emitDataChange (when server uses it)
data:change → collection room; document:change → document room; project:data:change → project room.