strangerSapien
strangerSapien
DTDrizzle Team
Created by Pepo on 12/26/2023 in #help
Filter Posts by categories?
this will correctly return even there are no posts
8 replies
DTDrizzle Team
Created by Pepo on 12/26/2023 in #help
Filter Posts by categories?
const postsByCategory = await db.select().from(categories)
.leftJoin(postsOnCategories, eq(categories.id, postsOnCategories.categoryId))
.leftJoin(posts, eq(postsOnCategories.postId, posts.id))
.where(eq(categories.id, 3))
const postsByCategory = await db.select().from(categories)
.leftJoin(postsOnCategories, eq(categories.id, postsOnCategories.categoryId))
.leftJoin(posts, eq(postsOnCategories.postId, posts.id))
.where(eq(categories.id, 3))
8 replies