pg_reactive Example 7 — Multiple WHERE Filters

Multi-Filter Dashboard

Three live subscriptions on the same table — products move between tiers as prices change
Budget
Mid-Range
Premium

Budget < $50

0
Waiting for data...

Mid-Range $50 – $200

0
Waiting for data...

Premium $200+

0
Waiting for data...
This demonstrates parameterized live queries. The same products table powers three independent subscriptions with different WHERE filters. When a product's price changes, it disappears from one tier and appears in another — entirely driven by the SQL delta engine.
-- Connect to the database
-- docker compose exec -T db psql -U postgres -d pg_reactive_test

-- Add a budget product (appears in left column)
INSERT INTO products (name, price, category)
VALUES ('USB Cable', 12.99, 'accessories');

-- Add a mid-range product (appears in center column)
INSERT INTO products (name, price, category)
VALUES ('Wireless Speaker', 89.99, 'audio');

-- Add a premium product (appears in right column)
INSERT INTO products (name, price, category)
VALUES ('4K Monitor', 549.99, 'displays');

-- Move a product between tiers by changing its price
-- (disappears from one column, appears in another)
UPDATE products SET price = 249.99
WHERE name = 'Wireless Speaker';

-- Remove a product
DELETE FROM products
WHERE name = 'USB Cable';