Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda