Skip to content

Commit

Permalink
Added projection fields to lieu-dit lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineludeau committed May 30, 2024
1 parent 5657c0a commit 6d912c9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/models/commune.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ async function getPopulatedCommune(codeCommune) {
}

async function getPopulatedVoie(idVoie) {
const voieFields = ['type', 'idVoie', 'banId', 'nomVoie', 'nomVoieAlt', 'sourceNomVoie', 'sources', 'codeCommune', 'nbNumeros', 'nbNumerosCertifies', 'displayBBox', 'dateMAJ']
const projectionFields = voie.type === 'voie'
? ['type', 'idVoie', 'banId', 'nomVoie', 'nomVoieAlt', 'sourceNomVoie', 'sources', 'codeCommune', 'nbNumeros', 'nbNumerosCertifies', 'displayBBox', 'dateMAJ']
: ['type', 'idVoie', 'banId', 'nomVoie', 'nomVoieAlt', 'sourceNomVoie', 'source', 'codeCommune', 'nbNumeros', 'nbNumerosCertifies', 'displayBBox', 'dateMAJ', 'position']

const voie = await mongo.db.collection('voies')
.findOne({idVoie}, {projection: fieldsToProj(voieFields)})
.findOne({idVoie}, {projection: fieldsToProj(projectionFields)})

if (!voie) {
return
Expand Down

0 comments on commit 6d912c9

Please sign in to comment.