Skip to content

Commit

Permalink
Query latest item
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervspl committed Mar 5, 2024
1 parent dbfbd40 commit aa7f2d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/server/src/api/item/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sql, and, eq } from 'drizzle-orm';
import { sql, and, eq, desc } from 'drizzle-orm';
import slugify from '@sindresorhus/slugify';

import * as i from '../../types';
Expand All @@ -24,7 +24,9 @@ async function queryItem(id: number, auctionHouseId: number) {
.select()
.from(items)
.where(and(eq(items.itemId, id), eq(items.auctionHouseId, auctionHouseId)))
.fullJoin(itemsMetadata, eq(items.itemId, itemsMetadata.id));
.fullJoin(itemsMetadata, eq(items.itemId, itemsMetadata.id))
.orderBy(desc(items.timestamp))
.limit(1);

// If not in DB, fetch item from TSM
if (queryResult == null || queryResult.length === 0 || queryResult[0].items == null) {
Expand Down

0 comments on commit aa7f2d6

Please sign in to comment.