Feathersjs REST 查询 $like

Feathersjs REST Query $like

我在使用 $like 运算符向 featherjs 发送 REST 查询时遇到问题。

Table:

ID 文本字段

1 安德烈亚斯

查询得到

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

返回行

查询得到 localhost:3030/table?textfield[$like]=andrea

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

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

所有此查询 return 0 行

模型是 Sequelize -> SQL 服务器

url有什么问题。

我通过在您的测试中添加一个 createdAt 和 updatedAt 字段来设置您的示例 table。

我使用了 Sequelize 的 feathersjs 模型 -> MySQL

Table:

ID 文本字段

1 安德烈亚斯

我使用邮递员来测试您的 GET 查询:

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

以下查询应该 return 什么都没有,因为 'andrea' 在数据库中不能完全匹配,星号 (*) 在 SQL LIKE 语法中不是通配符 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": []
}