export const categories = pgTable('categories', {
id: serial('id').primaryKey(),
name: Categories('name').notNull().unique(),
});
export const platformsToCategories = pgTable(
'platforms_to_categories',
{
platformId: integer('platform_id').references(() => platforms.id),
categoryId: integer('category_id').references(() => categories.id),
},
(t) => ({
pk: primaryKey(t.platformId, t.categoryId),
})
);
export const platformsToCategoriesRelations = relations(
platformsToCategories,
({ one }) => ({
platforms: one(platforms, {
fields: [platformsToCategories.platformId],
references: [platforms.id],
}),
categories: one(categories, {
fields: [platformsToCategories.categoryId],
references: [categories.id],
}),
})
);
export const getPlatformData = async (platformName: string) => {
const platformData = await db.query.platforms.findFirst({
where: eq(platforms.name, platformName),
with: {
// This doesn't work
founders: true,
// This works
catogories: true,
},
});
return platformData;
};