Feathersjs REST Query $like



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

桌子:

标识文本字段

1 安德烈亚斯

查询获取

本地主机:3030/表?文本字段[$like]=安德烈亚斯

重新调整行

查询获取本地主机:3030/表?文本字段[$like]=安德里亚

本地主机:3030/表?文本字段[$like]=andrea%

本地主机:3030/表?文本字段[$like]=安德里亚*

所有这些查询返回 0 行

模型是续集 -> SQL Server

网址有什么问题。

我在测试表中添加了一个 createdAt 和 updateAt 字段来设置您的示例。

我使用了 feathersjs Model of Sequelize -> MySQL

桌子:

标识文本字段

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

以下查询不应返回任何内容,因为"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": []
}

最新更新