Delet Subcategory Function
This commit is contained in:
@@ -12,26 +12,36 @@ class ProductService {
|
||||
|
||||
static async getDetailedProductById(productId) {
|
||||
return await db.getAsync(
|
||||
`SELECT p.*, c.name as category_name, s.name as subcategory_name
|
||||
FROM products p
|
||||
JOIN categories c ON p.category_id = c.id
|
||||
JOIN subcategories s ON p.subcategory_id = s.id
|
||||
WHERE p.id = ?`,
|
||||
`SELECT p.*, c.name as category_name
|
||||
FROM products p
|
||||
JOIN categories c ON p.category_id = c.id
|
||||
WHERE p.id = ?`,
|
||||
[productId]
|
||||
);
|
||||
}
|
||||
|
||||
static async getProductsByLocationAndCategory(locationId, categoryId, subcategoryId) {
|
||||
static async getProductsByLocationAndCategory(locationId, categoryId) {
|
||||
return await db.allAsync(
|
||||
`SELECT id, name, price, description, quantity_in_stock, photo_url
|
||||
FROM products
|
||||
WHERE location_id = ? AND category_id = ? AND subcategory_id = ?
|
||||
AND quantity_in_stock > 0
|
||||
ORDER BY name`,
|
||||
[locationId, categoryId, subcategoryId]
|
||||
FROM products
|
||||
WHERE location_id = ? AND category_id = ?
|
||||
AND quantity_in_stock > 0
|
||||
ORDER BY name`,
|
||||
[locationId, categoryId]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
static async getProductsByCategoryId(categoryId) {
|
||||
return await db.allAsync(
|
||||
`SELECT id, name, price, description, quantity_in_stock, photo_url
|
||||
FROM products
|
||||
WHERE category_id = ?
|
||||
AND quantity_in_stock > 0
|
||||
ORDER BY name`,
|
||||
[categoryId]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ProductService
|
||||
Reference in New Issue
Block a user