Major refactor

This commit is contained in:
Niklas Fondberg
2021-07-06 15:57:22 +02:00
parent 6bca11c62d
commit f66dbe33d7
21 changed files with 299 additions and 73 deletions
+16 -2
View File
@@ -1,4 +1,4 @@
import { Maybe } from '../types';
import { Maybe } from '../../types/types';
// Get syntax highlighting with vscode by installing "Comment tagged templates2
@@ -43,7 +43,12 @@ SELECT products.productid as id,
product_blacklist.updated_at
)
) FROM product_blacklist WHERE product_blacklist.product_id = products.productid
) AS blacklisting
) AS blacklisting,
( SELECT json_object_agg(fields.field, pf.value)
FROM "product-products_fields" pf
JOIN "product-fields" fields ON fields.fieldid = pf.fieldid
WHERE pf.productid = products.productid
) AS fields
FROM "product-products" products
`;
@@ -75,3 +80,12 @@ export function product(id: number) {
`
);
}
export function categoryProducts(categoryId: number) {
return (
baseQuery +
/* sql */ `
WHERE products.productid IN (SELECT product_id FROM product_category WHERE category_id = ${categoryId});
`
);
}