Cookbook

Common queries you can copy-paste.

Find entries about to expire

SELECT entry_did, bond_status, bond_expires_at
FROM bonds
WHERE bond_status = 'expiring_soon'
  AND bond_expires_at <= now() + interval '14 days'
ORDER BY bond_expires_at ASC;

Find unattested high-tier entries

SELECT e.entry_did
FROM entries e
LEFT JOIN attestations a ON a.entry_did = e.entry_did
WHERE e.bond_tier >= 2 AND a.id IS NULL;

Most prolific publishers in a namespace

SELECT publisher_did, COUNT(*) AS entries
FROM entries
WHERE entry_did LIKE 'did:oas:l1fe:%'
GROUP BY publisher_did
ORDER BY entries DESC
LIMIT 25;

Federated search by tag

SELECT entry_did, version, source_registry
FROM entries
WHERE tags CONTAINS 'rag'
  AND entry_type = 'agent'
ORDER BY published_at DESC
LIMIT 50;

(source_registry is a virtual column that tracks which federation peer served the row.)