Files
pokemon/src/db/relations.ts

37 lines
871 B
TypeScript
Raw Normal View History

import { defineRelations } from "drizzle-orm";
2026-02-15 15:25:08 -05:00
import * as schema from "./schema.ts";
export const relations = defineRelations(schema, (r) => ({
2026-03-09 15:43:37 -04:00
priceHistory: {
sku: r.one.skus({
from: r.priceHistory.skuId,
to: r.skus.skuId,
}),
},
skus: {
card: r.one.cards({
2026-02-23 19:05:55 -05:00
from: [r.skus.productId, r.skus.variant],
to: [r.cards.productId, r.cards.variant],
}),
2026-03-09 15:43:37 -04:00
history: r.many.priceHistory(),
},
cards: {
prices: r.many.skus(),
set: r.one.sets({
from: r.cards.setId,
to: r.sets.setId,
}),
tcgdata: r.one.tcgcards({
from: r.cards.productId,
to: r.tcgcards.productId,
}),
},
sets: {
cards: r.many.cards(),
},
tcgcards: {
cards: r.many.cards(),
},
}));