import { relations } from "drizzle-orm/relations";
import { users, userBuilds, userFavorites, userActivityLog } from "./schema";

export const userBuildsRelations = relations(userBuilds, ({one}) => ({
	user: one(users, {
		fields: [userBuilds.userId],
		references: [users.id]
	}),
}));

export const usersRelations = relations(users, ({many}) => ({
	userBuilds: many(userBuilds),
	userFavorites: many(userFavorites),
	userActivityLogs: many(userActivityLog),
}));

export const userFavoritesRelations = relations(userFavorites, ({one}) => ({
	user: one(users, {
		fields: [userFavorites.userId],
		references: [users.id]
	}),
}));

export const userActivityLogRelations = relations(userActivityLog, ({one}) => ({
	user: one(users, {
		fields: [userActivityLog.userId],
		references: [users.id]
	}),
}));