Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
How to do aggregation using match and lookup operation?

How to include aggregation in if condition ,do I need to use project or condition method in if condition above as well catalogue populate. I need to get the data from the mongo dB in the same order as video Ids array but it's coming in a different order so I decided to use aggregation to get the video in a proper order as in the video Ids array. Please help me to resolve this issue.

let filter = {$match:{
        customerId: customerId,
        _id: {
          $in: _.map(videoIds, id => mongoose.Types.ObjectId(id)) || []
        },
        _isDeleted: false,
        isActive: true
      },
      $lookup:{
        from:'catalogues',
        localField:'_isDeleted',
        foreignField:'_id',
        as:false
      
    }
    }

      if (!req.isLocationWhitelisted) {
        if (req._countryCode) {
          $or=
          filter.$match['languages.country'] = {
            $in: req._countryCode
          }
          filter.$lookup['languages.country'] = {
            $in: req._countryCode
          }
        ,
        filter.$match['languages.country.141'] = { $exists: true }
        filter.$lookup['languages.country.141'] = { $exists: true }
        }
      }
      
      let videoList = await Video.aggregate(filter);
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda