adding filter organization

This commit is contained in:
xfarrow
2024-03-20 10:48:46 +01:00
parent 6bd04adccb
commit 4f92f2dab5
2 changed files with 26 additions and 1 deletions

View File

@ -110,6 +110,17 @@ async function remove(organizationId, requester) {
return numberOfDeletedRows == 1;
}
/**
* Gets a list of Organizations given their prefix.
* E.g. "Can" --> "Canonical"
* @param {*} name
*/
async function filterByPrefix(name) {
return await knex('Organization')
.where('name', 'ilike', `${name}%`)
.select('name', 'location');
}
// Exporting a function
// means making a JavaScript function defined in one
// module available for use in another module.
@ -118,5 +129,6 @@ module.exports = {
createOrganization,
insert,
update,
remove
remove,
filterByPrefix
};