From b66254213e634733754e6e45337dcec0a56147e7 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 24 Apr 2023 01:05:24 +0100 Subject: [PATCH] Adjust PIS query Signed-off-by: Fred Boniface --- src/services/pis.services.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/pis.services.js b/src/services/pis.services.js index 3ee34fe..d7f6891 100644 --- a/src/services/pis.services.js +++ b/src/services/pis.services.js @@ -8,7 +8,9 @@ async function findPisByOrigDest(start,end) { log.out(`pisServices.findPisByOrigDest: Searching for PIS for Orig: ${start}, Dest: ${end}`, "dbug") const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase()) const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase()) - const search = db.query("pis", {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]}) + const query = {stops: {$elemMatch: {$eq: firstCrs, $position: 0}}, stops: {$elemMatch: {$eq: lastCrs, $position: {$exists: false}}}} + const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]} + const search = db.query("pis", query) return search }