pis #12
@ -9,19 +9,19 @@ async function findPisByOrigDest(start,end) {
|
|||||||
const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase())
|
const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase())
|
||||||
const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase())
|
const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase())
|
||||||
const query = {
|
const query = {
|
||||||
stops: {
|
stops: {
|
||||||
$all: [
|
$all: [
|
||||||
{ $elemMatch: { $eq: firstCrs } },
|
{ $elemMatch: { $eq: firstCrs } },
|
||||||
{ $elemMatch: { $eq: lastCrs } }
|
{ $elemMatch: { $eq: lastCrs } }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
$expr: {
|
$expr: {
|
||||||
$eq: [
|
$and: [
|
||||||
{ $arrayElemAt: [ "$stops", 0 ] },
|
{ $eq: [{ $arrayElemAt: [ "$stops", -1 ] }, lastCrs] },
|
||||||
firstCrs
|
{ $eq: [{ $arrayElemAt: [ "$stops", 0 ] }, firstCrs] }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]}
|
//const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]}
|
||||||
const search = db.query("pis", query)
|
const search = db.query("pis", query)
|
||||||
return search
|
return search
|
||||||
|
Loading…
Reference in New Issue
Block a user