This commit is contained in:
seb
2026-10-20 23:16:47 +02:00
parent bcefd81af7
commit 813e7c89b8
6 changed files with 24 additions and 3 deletions

View File

@@ -60,6 +60,9 @@ export const ARTICLE_LIST_COLUMNS = `
pic.thumbw AS thumbW,
pic.thumbh AS thumbH,
pic.thumbhash AS thumbHash,
pic.smallthumbw AS smallThumbW,
pic.smallthumbh AS smallThumbH,
pic.smallthumbbinary AS smallThumbBinary,
b.id AS brandId,
b.name AS brandName,
brand_pic.hash AS brandFullHash,

View File

@@ -11,7 +11,7 @@ export default function getCategoryArticles(provider) {
* @param {number} googleAuthId - The id of the Google auth user.
* @param {number} categoryId - The id of the category.
* @param {object} [tx] - Optional transaction to run within.
* @returns {Promise<Array<{id: number, sku: string, name: string, slug: string, net: number|null, taxRate: number|null, optionsCount: number, articleListCount: number, childCount: number, parentArticleId: number|null, parentSku: string|null, fullHash: string|null, thumbW: number|null, thumbH: number|null, thumbHash: string|null, brand: {id: number|null, name: string, fullHash: string|null, thumbW: number|null, thumbH: number|null, thumbHash: string|null}|null, articlewarehousesummary: Array<{id: number, articleId: number, warehouseId: number, warehouseName: string, stock: number}>, warehouses: Array<{id: number, name: string, stock: number}>}>>} The articles in the category.
* @returns {Promise<Array<{id: number, sku: string, name: string, slug: string, net: number|null, taxRate: number|null, optionsCount: number, articleListCount: number, childCount: number, parentArticleId: number|null, parentSku: string|null, fullHash: string|null, thumbW: number|null, thumbH: number|null, thumbHash: string|null, smallThumbW: number|null, smallThumbH: number|null, smallThumbBinary: string|null, brand: {id: number|null, name: string, fullHash: string|null, thumbW: number|null, thumbH: number|null, thumbHash: string|null}|null, articlewarehousesummary: Array<{id: number, articleId: number, warehouseId: number, warehouseName: string, stock: number}>, warehouses: Array<{id: number, name: string, stock: number}>}>>} The articles in the category.
*
* @example
* const articles = await store.category.getCategoryArticles(42, 5);

View File

@@ -56,6 +56,13 @@ export default function queryCategoryArticles(provider) {
const summaries = summaryMap.get(row.id) ?? [];
return {
...rest,
smallThumbW: rest.smallThumbW != null ? Number(rest.smallThumbW) : null,
smallThumbH: rest.smallThumbH != null ? Number(rest.smallThumbH) : null,
smallThumbBinary: rest.smallThumbBinary
? (Buffer.isBuffer(rest.smallThumbBinary)
? rest.smallThumbBinary.toString('base64')
: String(rest.smallThumbBinary))
: null,
track_stock: Boolean(rest.track_stock ?? 0),
// MSSQL returns BIT as boolean, SQLite as 0/1 integer. Normalize so both
// dialects expose isParent as a real boolean, matching article/getBySku.