[feat] implemented product variants

This commit is contained in:
2026-02-23 19:05:55 -05:00
parent 30433696e5
commit 240e4ce88b
6 changed files with 52 additions and 15 deletions

View File

@@ -148,10 +148,10 @@ async function syncProductLine(productLine: string, field: string, fieldValue: s
const detailData = await detailResponse.json();
await db.insert(schema.cards).values({
await db.insert(schema.tcgcards).values({
productId: item.productId,
originalProductName: item.productName,
productName: cleanProductName(item.productName),
productName: item.productName,
//productName: cleanProductName(item.productName),
rarityName: item.rarityName,
productLineName: item.productLineName,
productLineUrlName: item.productLineUrlName,
@@ -187,8 +187,8 @@ async function syncProductLine(productLine: string, field: string, fieldValue: s
Artist: detailData.formattedAttributes.Artist || null,
}).onDuplicateKeyUpdate({
set: {
originalProductName: item.productName,
productName: cleanProductName(item.productName),
productName: item.productName,
//productName: cleanProductName(item.productName),
rarityName: item.rarityName,
productLineName: item.productLineName,
productLineUrlName: item.productLineUrlName,

View File

@@ -23,6 +23,7 @@ async function createCollection(client: Client) {
name: 'cards',
fields: [
{ name: 'productId', type: 'int32' },
{ name: 'variant', type: 'string' },
{ name: 'productName', type: 'string' },
{ name: 'productLineName', type: 'string', facet: true },
{ name: 'rarityName', type: 'string', facet: true },
@@ -33,7 +34,7 @@ async function createCollection(client: Client) {
{ name: 'Artist', type: 'string' },
{ name: 'sealed', type: 'bool' },
],
default_sorting_field: 'productId',
//default_sorting_field: 'productId',
});
console.log(chalk.green('Collection "cards" created successfully.'));
} else {
@@ -54,6 +55,7 @@ async function preloadSearchIndex() {
await client.collections('cards').documents().import(pokemon.map(card => ({
productId: card.productId,
variant: card.variant,
productName: card.productName,
productLineName: card.productLineName,
rarityName: card.rarityName,