使用$ like运算符向featherjs发送REST查询时遇到问题。
表:
ID Textfield
1 andreas
查询获取
本地主机:3030 /表文本字段[$等] =安德烈亚斯
撤回行
查询获取 本地主机:3030 /表文本字段[$等] =安德烈
本地主机:3030 /表文本字段[$等] =安德烈%
本地主机:3030 /表文本字段[$等] =安德烈*
所有这些查询都返回0行
模型是Sequelize - > SQL Server
网址错误。
答案 0 :(得分:0)
我通过在测试表中添加createdAt和updatedAt字段来设置您的示例。
我使用了羽毛js模型的Sequelize - > MySQL的
表:
ID Textfield
1 andreas
我使用邮递员来测试你的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": []
}