4

I have an problem to send a REST query to featherjs with the $like operator.

Table:

ID Textfield

1 andreas

Query get

localhost:3030/table?textfield[$like]=andreas

returs the row

Query get localhost:3030/table?textfield[$like]=andrea

localhost:3030/table?textfield[$like]=andrea%

localhost:3030/table?textfield[$like]=andrea*

all this query return 0 rows

Model is Sequelize -> SQL Server

Whats wrong with the url.

Andreas
  • 43
  • 3
  • To give you some information look at this [Issue](https://github.com/feathersjs/feathers/issues/334) – HorseT May 19 '17 at 10:35

1 Answers1

3

I setup your example with the addition of a createdAt and updatedAt field in your test table.

I used a feathersjs Model of Sequelize -> MySQL

Table:

ID Textfield

1 andreas

I used postman to test your GET queries:

localhost:3030/table?textfield[$like]=andreas 

returns:

{
  "total": 1,
  "limit": 20,
  "skip": 0,
  "data": [
    {
     "id": 1,
      "textfield": "andreas",
      "createdAt": "2017-06-05T11:33:38.000Z",
      "updatedAt": null
    }
  ]
}

localhost:3030/table?textfield[$like]=andrea%

returns:

{
  "total": 1,
  "limit": 20,
  "skip": 0,
  "data": [
    {
     "id": 1,
      "textfield": "andreas",
      "createdAt": "2017-06-05T11:33:38.000Z",
      "updatedAt": null
    }
  ]
}

localhost:3030/table?textfield[$like]=%drea%

returns:

{
  "total": 1,
  "limit": 20,
  "skip": 0,
  "data": [
    {
     "id": 1,
      "textfield": "andreas",
      "createdAt": "2017-06-05T11:33:38.000Z",
      "updatedAt": null
    }
  ]
}

The following queries should return nothing because 'andrea' can not be exactly matched in the database and the asterisk (*) is not a wild card in the SQL LIKE syntax https://www.w3schools.com/SQL/sql_like.asp :

localhost:3030/table?textfield[$like]=andrea
localhost:3030/table?textfield[$like]=andrea*

{
  "total": 0,
  "limit": 20,
  "skip": 0,
  "data": []
}
user3139574
  • 1,119
  • 10
  • 6