Add creators to the response
This commit is contained in:
3 files changed
+14
-3
No files matched your search
@@ -3,7 +3,7 @@
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: Mar 24, 2026 at 09:47 PM
|
||||
-- Generation Time: Mar 24, 2026 at 10:33 PM
|
||||
-- Server version: 10.11.14-MariaDB-0ubuntu0.24.04.1
|
||||
-- PHP Version: 8.3.30
|
||||
|
||||
@@ -111,6 +111,7 @@ CREATE TABLE `loaderupdates` (
|
||||
CREATE TABLE `mods` (
|
||||
`id` bigint(20) NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`creators` text NOT NULL DEFAULT '[]',
|
||||
`description` text DEFAULT NULL,
|
||||
`downloadCount` bigint(20) NOT NULL DEFAULT 0,
|
||||
`hidden` tinyint(1) NOT NULL DEFAULT 1
|
||||
|
||||
@@ -106,6 +106,7 @@ export const cdnFiles = mysqlTable('cdnfiles', {
|
||||
export const mods = mysqlTable('mods', {
|
||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||
name: text('name').notNull(),
|
||||
creators: text('creators').default('{}').notNull(),
|
||||
description: text('description').notNull(),
|
||||
downloadCount: bigint('downloadCount', { mode: 'number' })
|
||||
.notNull()
|
||||
|
||||
@@ -2,9 +2,10 @@ import {
|
||||
games,
|
||||
launcherVersionManifest,
|
||||
mods,
|
||||
modVersions
|
||||
modVersions,
|
||||
users
|
||||
} from '../../../lib/tables'
|
||||
import { and, asc, desc, eq } from 'drizzle-orm'
|
||||
import { and, asc, desc, eq, inArray, sql } from 'drizzle-orm'
|
||||
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
|
||||
import { Context } from 'elysia'
|
||||
|
||||
@@ -83,6 +84,7 @@ export const handler = async (context: Context) => {
|
||||
.select({
|
||||
id: mods.id,
|
||||
name: mods.name,
|
||||
creators: mods.creators,
|
||||
description: mods.description,
|
||||
downloadCount: mods.downloadCount
|
||||
})
|
||||
@@ -126,10 +128,17 @@ export const handler = async (context: Context) => {
|
||||
|
||||
if (!download || !downloads[download]) return
|
||||
|
||||
const creators = await db
|
||||
.select({ username: users.username })
|
||||
.from(users)
|
||||
.where(inArray(users.id, JSON.parse(v.creators)))
|
||||
.execute()
|
||||
|
||||
return {
|
||||
id: v.id,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
creators: creators.map(u => u.username),
|
||||
downloads: v.downloadCount,
|
||||
released: vi[vi.length - 1].releaseDate,
|
||||
updated: vi[0].releaseDate,
|
||||
|
||||
Reference in new issue
Block a user