[bugfix] search moved to components

This commit is contained in:
2026-02-17 13:27:48 -05:00
parent 9b63afb342
commit 85fbaf267f
3 changed files with 33 additions and 7 deletions

View File

@@ -1,16 +1,22 @@
---
//import { eq } from 'drizzle-orm';
import { isConditionalExpression } from 'typescript';
import { client } from '../db/typesense.ts';
import { db } from '../db';
import RarityIcon from './RarityIcon.astro';
//import * as schema from '../db/schema.ts';
// Get some sample Pokemon data from the database
//const pokemon = await db.select().from(schema.cards).where(eq(schema.cards.productLineName, "pokemon")).limit(256);
const { query } = Astro.props;
const searchResults = await client.collections('cards').documents().search({
q: query,
query_by: 'productLineName,productName,setName,number,rarityName',
per_page: 250,
});
const productIds = searchResults.hits?.map(hit => hit.document.productId) ?? [];
// get pokemon data with prices and set info using searchResults and then query the database for each card to get the prices and set info
const pokemon = await db.query.cards.findMany({
where: { productLineName: "pokemon", },
orderBy: (cards, { desc }) => [desc(cards.marketPrice)],
limit: 320,
where: { productId: { in: productIds, }, },
with: {
prices: true,
set: true,