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

129
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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