Added licenses to search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Gregory Ballantine
2024-05-21 10:33:07 -04:00
parent f44b0e217a
commit 6171a968c1
2 changed files with 65 additions and 22 deletions

View File

@ -9,7 +9,20 @@ exports.getSearch = async function(req, res) {
let query = req.query.query;
// fetch inventory items from database based on search query
const results = await Item.findAll({
const item_results = await Item.findAll({
where: {
name: {
[Op.like]: '%' + query + '%',
}
},
limit: 10,
order: [
['updatedAt', 'DESC'],
],
});
// fetch licenses from database based on search query
const license_results = await License.findAll({
where: {
name: {
[Op.like]: '%' + query + '%',
@ -23,6 +36,7 @@ exports.getSearch = async function(req, res) {
res.render('search.twig', {
query: query,
results: results,
item_results: item_results,
license_results: license_results,
});
};