pis #12
@ -5,7 +5,7 @@ const log = require('../utils/log.utils')
|
||||
const clean = require('../utils/sanitizer.utils')
|
||||
|
||||
async function findPisByOrigDest(start,end) {
|
||||
log.out(`pisServices.findPisByOrigDest: Searching for PIS for Orig: ${start}, Dest: ${end}`, "dbug")
|
||||
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 query = {
|
||||
@ -17,13 +17,13 @@ async function findPisByOrigDest(start,end) {
|
||||
},
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: [{ $arrayElemAt: [ "$stops", -1 ] }, lastCrs] },
|
||||
{ $eq: [{ $arrayElemAt: [ "$stops", 0 ] }, firstCrs] }
|
||||
{ $eq: [{ $arrayElemAt: [ '$stops', -1 ] }, lastCrs] },
|
||||
{ $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', query)
|
||||
return search
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user