gameflow-deck/src/bun/api/schema/emulators.ts
Simeon Radivoev 3750e9ed8f
feat: Implemented emulator installation
feat: Updated romm API version
feat: Updated es-de rules
feat: Added tabs to game details
refactor: returned to global query definitions to help with typescript performance
2026-03-22 01:11:21 +02:00

48 lines
No EOL
1.8 KiB
TypeScript

import { relations, sql } from "drizzle-orm";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const emulators = sqliteTable('emulators', {
name: text().primaryKey().unique(),
fullname: text(),
systempath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
staticpath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
corepath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
androidpackage: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
winregistrypath: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`),
});
export const systems = sqliteTable('systems', {
name: text().primaryKey().unique(),
fullname: text(),
path: text(),
extension: text({ mode: 'json' }).notNull().$type<string[]>().default(sql`(json_array())`)
});
export const systemsRelations = relations(systems, ({ many }) =>
({
commands: many(commands)
}));
export const systemMappings = sqliteTable('systemMappings', {
source: text(),
sourceSlug: text(),
sourceId: integer(),
system: text().notNull().references(() => systems.name)
});
export const systemMappingsRelations = relations(systemMappings, ({ one }) => ({
system: one(systems, { fields: [systemMappings.system], references: [systems.name] })
}));
export const commands = sqliteTable('commands', {
system: text().references(() => systems.name, { onDelete: 'cascade', onUpdate: 'cascade' }),
label: text(),
command: text().notNull()
});
export const commandsRelations = relations(commands, ({ one }) => ({
system: one(systems, {
fields: [commands.system],
references: [systems.name],
}),
}));