alloc / tusken

100% type-safe query builder compatible with any Postgres client 🐘 Generated table/function types, tree-shakable, implicit type casts, and more
Other
223 stars 3 forks source link

Support spreading a row into a selection mapping #9

Open aleclarson opened 2 years ago

aleclarson commented 2 years ago
db.select(
  t.tweet(tweet => ({
    ...tweet,
    author: db.get(t.user, tweet.author),
  }))
)

By spreading tweet into the mapping, all columns should be selected and an additional author column is added (which overrides the tweet.author column).

Implementing this should be straight-forward.
Just need to define the ownKeys trap on the proxy handler that tweet uses. https://github.com/alloc/tusken/blob/96b4ddd24e30ae5f55936f29ade1556319b66924/src/database/selector.ts#L17