Subquery/join in relational query
are the following queries identical?
await db.query.posts.findFirst({
where: and(
eq(posts.type, 'blog'),
inArray(
posts.userId,
db
.select({ id: users.id })
.from(users)
.where(and(eq(users.id, userId), isNotNull(users.email)))
)
)
});await db.query.posts.findFirst({
where: and(
eq(posts.type, 'blog'),
inArray(
posts.userId,
db
.select({ id: users.id })
.from(users)
.where(and(eq(users.id, userId), isNotNull(users.email)))
)
)
});await db.query.posts.findFirst({
with: { user: true },
where: and(
eq(posts.type, 'blog'),
isNotNull(users.email)
)
});await db.query.posts.findFirst({
with: { user: true },
where: and(
eq(posts.type, 'blog'),
isNotNull(users.email)
)
});