Add product search (#64)
This commit is contained in:
@@ -77,17 +77,18 @@ FROM "product-products" products
|
||||
|
||||
export function products(input: ProductsFilterInput) {
|
||||
const limit = input.pagination.limit ?? 100;
|
||||
const filter = input.filter;
|
||||
const filter = input.filter ?? null;
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
${
|
||||
filter.visible != null
|
||||
filter?.visible != null
|
||||
? /* sql */ `
|
||||
WHERE products.visible = ${filter?.visible ? '1' : '0'}
|
||||
AND products.browsable = ${filter?.browsable ? '1' : '0'}`
|
||||
: ``
|
||||
}
|
||||
ORDER BY products.inserted DESC
|
||||
LIMIT ${limit}
|
||||
`
|
||||
);
|
||||
@@ -98,7 +99,7 @@ export function productsTotal(input: ProductsFilterInput) {
|
||||
return /*sql */ `
|
||||
SELECT count(*) FROM "product-products" products
|
||||
${
|
||||
filter.visible != null
|
||||
filter?.visible != null
|
||||
? /* sql */ `
|
||||
WHERE products.visible = ${filter?.visible ? '1' : '0'}
|
||||
AND products.browsable = ${filter?.browsable ? '1' : '0'}`
|
||||
@@ -125,6 +126,15 @@ export function categoryProducts(categoryId: number) {
|
||||
);
|
||||
}
|
||||
|
||||
export function designerProducts() {
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
WHERE products.designerid = ?;
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
export function keywordProducts(keywordId: number) {
|
||||
return (
|
||||
baseQuery +
|
||||
@@ -133,3 +143,12 @@ export function keywordProducts(keywordId: number) {
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
export function searchByFieldValue(fieldid: number) {
|
||||
return (
|
||||
baseQuery +
|
||||
/* sql */ `
|
||||
WHERE products.productid IN (SELECT productid FROM "product-products_fields" WHERE fieldid = ${fieldid} AND LOWER(value) LIKE ? LIMIT 5000); -- limit to 5000 results
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user