tusken
tusken copied to clipboard
Add `db.list` for getting multiple rows by primary key
We can't just let db.get take an array of keys, because we want to support array-based keys.
// Order is guaranteed to match the `userIds` array.
const rows = await db.list(t.user, userIds)
This is not simply a shorthand method for db.select(...).where(({ pk }) => pk.in(array)), because the result order is guaranteed to match the input array.
Note: When using this method, the primary key will always be included in the resulting objects.
We can probably use WITH ORDINALITY to achieve this without JS massaging 👀
We can't just let
db.gettake an array of keys, because we want to support array-based keys.
Now that we have runtime type information for columns, this isn't a constraint anymore. 👀