Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!