0

In my angular2 project i need to search data from the database using loopback how can i implement this using "wildcard" query in find(). Thanks in advance. Please help me.

Here is my query

this.model.find({
     "where": {
       "wildcard": {
         "name": "*a*"
        }
       }
  })

My result is an empty array.Please help me.

Khushi
  • 1,759
  • 6
  • 26
  • 45

3 Answers3

0

This is how I do it in Mysql:

this.model.find({
   where:{
      name: "%a%"
   }
})
user257980
  • 1,059
  • 2
  • 15
  • 31
0

You can use regular expressions:

this.model.find({
    where: {
        property: {
            regexp: <expression>
        }
    }
})

You can read more here

Or you can use like/nlike you can reed about this here

Mantas
  • 71
  • 7
0

I recommends you use a loopback-sdk-builder to generate api rest in your frontend proyect, and then consumes the find method. Simply like

getAll(): Observable<Model> {
  return this.myApiModel.find();
}