mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
33 lines
806 B
TypeScript
33 lines
806 B
TypeScript
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
|
/* eslint-disable @typescript-eslint/no-extra-non-null-assertion */
|
|
|
|
import prisma from "../internal/db/database";
|
|
import { parsePlatform } from "../internal/utils/parseplatform";
|
|
import tsquery from "pg-tsquery";
|
|
|
|
export default defineEventHandler(async (h3) => {
|
|
const query = getQuery(h3);
|
|
const name = query.name?.toString()!!;
|
|
const platform = parsePlatform(query.platform?.toString()!!)!!;
|
|
|
|
const parser = tsquery({});
|
|
|
|
return await prisma.ludusaviEntry.findMany({
|
|
orderBy: {
|
|
_relevance: {
|
|
fields: ["name"],
|
|
search: parser(name),
|
|
sort: "desc",
|
|
},
|
|
},
|
|
include: {
|
|
entries: {
|
|
where: {
|
|
platform,
|
|
},
|
|
},
|
|
},
|
|
take: 20,
|
|
});
|
|
});
|