Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (28 sloc) 1.21 KB
{{ 'id,category,supplier,nameContains' | importRequestParams }}
{{ qs.limit ?? 100 | assignTo: limit }}
{{ `select p.Id,
ProductName,
c.CategoryName Category,
s.CompanyName Supplier,
QuantityPerUnit,
${sqlCurrency("UnitPrice")} UnitPrice,
UnitsInStock, UnitsOnOrder, ReorderLevel
from Product p
inner join Category c on p.CategoryId = c.Id
inner join Supplier s on p.SupplierId = s.Id
where Discontinued = 0`
| assignTo: sql }}
{{#if !isEmpty(PathArgs)}}
{{ `${sql} and p.Id = @id` | dbSingle({ id: PathArgs[0] })
| return }}
{{/if}}
{{#if id}} {{ 'p.Id = @id' | addTo: filters }} {{/if}}
{{#if category}} {{ 'c.CategoryName = @category' | addTo: filters }} {{/if}}
{{#if supplier}} {{ 's.CompanyName = @supplier' | addTo: filters }} {{/if}}
{{#if nameContains}} {{ 'ProductName LIKE @name' | addTo: filters }} {{/if}}
{{#if !isEmpty(filters)}}
{{ `${sql} and ${join(filters, ' and ')}` | assignTo: sql }}
{{/if}}
{{ `${sql} ORDER BY CompanyName ${sqlLimit(limit)}` | assignTo: sql }}
{{ sql | dbSelect({ id, category, supplier, name: `%${nameContains}%` })
| return }}
You can’t perform that action at this time.