Add find PIS by code functionality

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface
2023-05-24 20:42:32 +01:00
parent b119f126b9
commit 11ece9c80e
4 changed files with 31 additions and 3 deletions

View File

@@ -24,11 +24,22 @@ async function findPisByOrigDest(start,end) {
};
//const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]}
const search = db.query('pis', query);
return search;
return await search;
}
async function findPisByCode(code) {
log.out(`pisServices.findPisByCode: Searching for PIS code: ${code}`);
const cleanCode = clean.removeNonNumeric(code);
const query = {
code: cleanCode
};
const search = db.query('pis', query);
return await search;
}
// Hopefully at some point, I will also be able to implement a find PIS code by headcode option.
module.exports = {
findPisByOrigDest
findPisByOrigDest,
findPisByCode
};