import { relations } from "drizzle-orm/relations";
import { chats, reply, users, tokens } from "./schema";

export const replyRelations = relations(reply, ({one}) => ({
	chat: one(chats, {
		fields: [reply.chat_id],
		references: [chats.id]
	}),
}));

export const chatsRelations = relations(chats, ({many}) => ({
	replies: many(reply),
}));

export const tokensRelations = relations(tokens, ({one}) => ({
	user: one(users, {
		fields: [tokens.email],
		references: [users.email]
	}),
}));

export const usersRelations = relations(users, ({many}) => ({
	tokens: many(tokens),
}));