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

118
Visualizações
Cannot read property 'match' of null"

So I'm working on search bar function, where you can search name, email, phone, personal number, I had already name and email and it was working good, however, I added phone and personal number and I started to get these error... I can search right now phone and email, but when I try to search personal number and name I'm getting Cannot read property 'match' of null" Error from the console...

 user: async () => {
  const accessibleUsers = await UserController.getAccessible(req);
  const userCollection = db.collection(User.tableName);
  const nativeResults = await userCollection.find({
    _id: { $in: accessibleUsers.map((val) => ObjectID(val)) },
    vc_isLogEntity: false,
    // deleted: false, //TODO RN-732 Add back
    $or: [
      { email: matchRegex },
      { firstName: matchRegex },
      { lastName: matchRegex },
      { phone: matchRegex },
      { personnelNumber: matchRegex }
    ]
  }, {_id: 1}).toArray();

  const users = await User
    .find(nativeResults.map(r => `${r._id}`))
    .populate('role');
  return users.map(user => ({
    type: 'user',
    value: user,
    ...getMatches(user, ['email', 'firstName', 'lastName', 'phone', 'personnelNumber'])
  }));

I just added { phone: matchRegex },{ personnelNumber: matchRegex } and 'phone', 'personnelNumber' to the code.. Can someone help me how to avoid this error ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think personal Number check the spelling and check are you searching for the full name / FirstName and lastName ?

about 4 years ago · Juan Pablo Isaza Relatório
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