How to assert the expect number of result rows of a sub-query in PostgreSQL?
Often times I find myself writing code such as: const fooId = await pool.oneFirst(sql` SELECT id FROM foo WHERE nid = 'BAR' `); await pool.query(sql` INSERT INTO bar (foo_id) VALUES (${fooId}) `); oneFirst is a Slonik query method that ensures…