I am trying to select cards with the assigned user. I am joining the cards collection with the users collection with user_id. I am then using select and want the user to be under user on the card. However, because I am using a leftJoin the returned type just makes every field of user optional rather than the user itself as optional.
const { data: cards = [] } = useLiveQuery(
(q) =>
q
.from({ card: cardCollection })
.leftJoin({ user: userCollection }, ({ card, user }) =>
eq(card.user_id, user.id),
)
.select(({ card, user, }) => ({
...card,
user: user,
})),
[],
);
Is this a bug or is there a solution for this?