Again, adjust PIS query

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-04-24 01:33:15 +01:00
parent 43dba62434
commit 6ca8de8c75

View File

@ -10,22 +10,20 @@ async function findPisByOrigDest(start,end) {
const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase())
const query = {
stops: {
$elemMatch: {
$eq: firstCrs,
$position: 0
}
$all: [
{ $elemMatch: { $eq: firstCrs } },
{ $elemMatch: { $eq: lastCrs } }
]
},
stops: {
$elemMatch: {
$eq: lastCrs,
$position: {
$exists: false
}
}
$expr: {
$eq: [
{ $arrayElemAt: [ "$stops", 0 ] },
firstCrs
]
}
}
const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]}
const search = db.query("pis", query)
const search = db.query("pis", oldQuery)
return search
}