mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -04:00
Define seasons relations
This commit is contained in:
parent
b1df97f767
commit
f9554bd128
@ -95,7 +95,7 @@ export const entryTranslations = schema.table(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const entryRelations = relations(entries, ({ one, many }) => ({
|
export const entryRelations = relations(entries, ({ one, many }) => ({
|
||||||
translations: many(entryTranslations, { relationName: "entryTranslations" }),
|
translations: many(entryTranslations, { relationName: "entry_translations" }),
|
||||||
evj: many(entryVideoJoin, { relationName: "evj_entry" }),
|
evj: many(entryVideoJoin, { relationName: "evj_entry" }),
|
||||||
show: one(shows, {
|
show: one(shows, {
|
||||||
relationName: "show_entries",
|
relationName: "show_entries",
|
||||||
@ -106,7 +106,7 @@ export const entryRelations = relations(entries, ({ one, many }) => ({
|
|||||||
|
|
||||||
export const entryTrRelations = relations(entryTranslations, ({ one }) => ({
|
export const entryTrRelations = relations(entryTranslations, ({ one }) => ({
|
||||||
entry: one(entries, {
|
entry: one(entries, {
|
||||||
relationName: "entryTranslations",
|
relationName: "entry_translations",
|
||||||
fields: [entryTranslations.pk],
|
fields: [entryTranslations.pk],
|
||||||
references: [entries.pk],
|
references: [entries.pk],
|
||||||
}),
|
}),
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { relations } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
date,
|
date,
|
||||||
index,
|
index,
|
||||||
@ -67,3 +68,22 @@ export const seasonTranslations = schema.table(
|
|||||||
},
|
},
|
||||||
(t) => [primaryKey({ columns: [t.pk, t.language] })],
|
(t) => [primaryKey({ columns: [t.pk, t.language] })],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const seasonRelations = relations(seasons, ({ one, many }) => ({
|
||||||
|
translations: many(seasonTranslations, {
|
||||||
|
relationName: "season_translations",
|
||||||
|
}),
|
||||||
|
show: one(shows, {
|
||||||
|
relationName: "show_seasons",
|
||||||
|
fields: [seasons.showPk],
|
||||||
|
references: [shows.pk],
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const seasonTrRelations = relations(seasonTranslations, ({ one }) => ({
|
||||||
|
season: one(seasons, {
|
||||||
|
relationName: "season_translation",
|
||||||
|
fields: [seasonTranslations.pk],
|
||||||
|
references: [seasons.pk],
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
import { image, language, schema } from "./utils";
|
import { image, language, schema } from "./utils";
|
||||||
import { entries } from "./entries";
|
import { entries } from "./entries";
|
||||||
|
import { seasons } from "./seasons";
|
||||||
|
|
||||||
export const showKind = schema.enum("show_kind", ["serie", "movie"]);
|
export const showKind = schema.enum("show_kind", ["serie", "movie"]);
|
||||||
export const showStatus = schema.enum("show_status", [
|
export const showStatus = schema.enum("show_status", [
|
||||||
@ -121,29 +122,30 @@ export const showTranslations = schema.table(
|
|||||||
|
|
||||||
export const showsRelations = relations(shows, ({ many, one }) => ({
|
export const showsRelations = relations(shows, ({ many, one }) => ({
|
||||||
selectedTranslation: many(showTranslations, {
|
selectedTranslation: many(showTranslations, {
|
||||||
relationName: "selectedTranslation",
|
relationName: "selected_translation",
|
||||||
}),
|
}),
|
||||||
translations: many(showTranslations, { relationName: "showTranslations" }),
|
translations: many(showTranslations, { relationName: "show_translations" }),
|
||||||
originalTranslation: one(showTranslations, {
|
originalTranslation: one(showTranslations, {
|
||||||
relationName: "originalTranslation",
|
relationName: "original_translation",
|
||||||
fields: [shows.pk, shows.originalLanguage],
|
fields: [shows.pk, shows.originalLanguage],
|
||||||
references: [showTranslations.pk, showTranslations.language],
|
references: [showTranslations.pk, showTranslations.language],
|
||||||
}),
|
}),
|
||||||
entries: many(entries, { relationName: "show_entries" }),
|
entries: many(entries, { relationName: "show_entries" }),
|
||||||
|
seasons: many(seasons, { relationName: "show_seasons" }),
|
||||||
}));
|
}));
|
||||||
export const showsTrRelations = relations(showTranslations, ({ one }) => ({
|
export const showsTrRelations = relations(showTranslations, ({ one }) => ({
|
||||||
show: one(shows, {
|
show: one(shows, {
|
||||||
relationName: "showTranslations",
|
relationName: "show_translations",
|
||||||
fields: [showTranslations.pk],
|
fields: [showTranslations.pk],
|
||||||
references: [shows.pk],
|
references: [shows.pk],
|
||||||
}),
|
}),
|
||||||
selectedTranslation: one(shows, {
|
selectedTranslation: one(shows, {
|
||||||
relationName: "selectedTranslation",
|
relationName: "selected_translation",
|
||||||
fields: [showTranslations.pk],
|
fields: [showTranslations.pk],
|
||||||
references: [shows.pk],
|
references: [shows.pk],
|
||||||
}),
|
}),
|
||||||
originalTranslation: one(shows, {
|
originalTranslation: one(shows, {
|
||||||
relationName: "originalTranslation",
|
relationName: "original_translation",
|
||||||
fields: [showTranslations.pk, showTranslations.language],
|
fields: [showTranslations.pk, showTranslations.language],
|
||||||
references: [shows.pk, shows.originalLanguage],
|
references: [shows.pk, shows.originalLanguage],
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user