FluxbaseAdminRealtime
Realtime Admin Manager
Provides methods for enabling and managing realtime subscriptions on database tables. When enabled, changes to a table (INSERT, UPDATE, DELETE) are automatically broadcast to WebSocket subscribers.
Example
Section titled “Example”const realtime = client.admin.realtime
// Enable realtime on a tableawait realtime.enableRealtime('products')
// Enable with optionsawait realtime.enableRealtime('orders', { events: ['INSERT', 'UPDATE'], exclude: ['internal_notes', 'raw_data']})
// List all realtime-enabled tablesconst { tables } = await realtime.listTables()
// Check status of a specific tableconst status = await realtime.getStatus('public', 'products')
// Disable realtimeawait realtime.disableRealtime('public', 'products')Constructors
Section titled “Constructors”new FluxbaseAdminRealtime()
Section titled “new FluxbaseAdminRealtime()”new FluxbaseAdminRealtime(
fetch):FluxbaseAdminRealtime
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | FluxbaseFetch |
Returns
Section titled “Returns”Methods
Section titled “Methods”disableRealtime()
Section titled “disableRealtime()”disableRealtime(
schema,table):Promise<object>
Disable realtime on a table
Removes the realtime trigger from a table. Existing subscribers will stop receiving updates for this table.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
schema | string | Schema name |
table | string | Table name |
Returns
Section titled “Returns”Promise<object>
Promise resolving to success message
| Name | Type |
|---|---|
message | string |
success | boolean |
Example
Section titled “Example”await client.admin.realtime.disableRealtime('public', 'products')console.log('Realtime disabled')enableRealtime()
Section titled “enableRealtime()”enableRealtime(
table,options?):Promise<EnableRealtimeResponse>
Enable realtime on a table
Creates the necessary database triggers to broadcast changes to WebSocket subscribers. Also sets REPLICA IDENTITY FULL to include old values in UPDATE/DELETE events.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
table | string | Table name to enable realtime on |
options? | object | Optional configuration |
options.events? | ("DELETE" | "INSERT" | "UPDATE")[] | - |
options.exclude? | string[] | - |
options.schema? | string | - |
Returns
Section titled “Returns”Promise<EnableRealtimeResponse>
Promise resolving to EnableRealtimeResponse
Example
Section titled “Example”// Enable realtime on products table (all events)await client.admin.realtime.enableRealtime('products')
// Enable on a specific schemaawait client.admin.realtime.enableRealtime('orders', { schema: 'sales'})
// Enable specific events onlyawait client.admin.realtime.enableRealtime('audit_log', { events: ['INSERT'] // Only broadcast inserts})
// Exclude large columns from notificationsawait client.admin.realtime.enableRealtime('posts', { exclude: ['content', 'raw_html'] // Skip these in payload})getStatus()
Section titled “getStatus()”getStatus(
schema,table):Promise<RealtimeTableStatus>
Get realtime status for a specific table
Returns the realtime configuration for a table, including whether it’s enabled, which events are tracked, and which columns are excluded.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
schema | string | Schema name |
table | string | Table name |
Returns
Section titled “Returns”Promise<RealtimeTableStatus>
Promise resolving to RealtimeTableStatus
Example
Section titled “Example”const status = await client.admin.realtime.getStatus('public', 'products')
if (status.realtime_enabled) { console.log('Events:', status.events.join(', ')) console.log('Excluded:', status.excluded_columns?.join(', ') || 'none')} else { console.log('Realtime not enabled')}listTables()
Section titled “listTables()”listTables(
options?):Promise<ListRealtimeTablesResponse>
List all realtime-enabled tables
Returns a list of all tables that have realtime enabled, along with their configuration (events, excluded columns, etc.).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? | object | Optional filter options |
options.includeDisabled? | boolean | - |
Returns
Section titled “Returns”Promise<ListRealtimeTablesResponse>
Promise resolving to ListRealtimeTablesResponse
Example
Section titled “Example”// List all enabled tablesconst { tables, count } = await client.admin.realtime.listTables()console.log(`${count} tables have realtime enabled`)
tables.forEach(t => { console.log(`${t.schema}.${t.table}: ${t.events.join(', ')}`)})
// Include disabled tablesconst all = await client.admin.realtime.listTables({ includeDisabled: true })updateConfig()
Section titled “updateConfig()”updateConfig(
schema,table,config):Promise<object>
Update realtime configuration for a table
Modifies the events or excluded columns for a realtime-enabled table without recreating the trigger.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
schema | string | Schema name |
table | string | Table name |
config | UpdateRealtimeConfigRequest | New configuration |
Returns
Section titled “Returns”Promise<object>
Promise resolving to success message
| Name | Type |
|---|---|
message | string |
success | boolean |
Example
Section titled “Example”// Change which events are trackedawait client.admin.realtime.updateConfig('public', 'products', { events: ['INSERT', 'UPDATE'] // Stop tracking deletes})
// Update excluded columnsawait client.admin.realtime.updateConfig('public', 'posts', { exclude: ['raw_content', 'search_vector']})
// Clear excluded columnsawait client.admin.realtime.updateConfig('public', 'posts', { exclude: [] // Include all columns again})