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

128
Views
Angular2 Like request MongoDB

I want to do a pretty simple thing, a function that does a query to mongoDB using a Like. But I don't seem to make it works.

At the moment it looks like this :

searchChannel(valueToSearch:string){
    this.items = Channels.find({'title':'/' + valueToSearch + '/'});
}

I tried /valueToSearch/ too, but it doesn't return any result.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Ok so... the issue is likely because you're inserting / characters into your mongo query. I think you want something like this:

searchChannel(valueToSearch:string){
    this.items = Channels.find({'title': valueToSearch });
}

Unless the / characters are part of your stored content, they shouldn't be added to your search string.

over 4 years ago · Santiago Trujillo Report

0

To construct a regular expression from string you can use RegExp

searchChannel(valueToSearch:string){
    this.items = Channels.find({'title': new RegExp(valueToSearch)});
}
over 4 years ago · Santiago Trujillo 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!