问题描述
我在模型中有一个object
字段,其内容为:(使用mysql-connector
):
@property({
type: 'object',})
Data?: object;
我想在Data
字段中进行搜索,所以我尝试了:
// like
myRepo.find({
where: {
Data: {
like: {
mykey: "myvalue"
}
}
}
})
// equal
myRepo.find({
where: {
Data: {
eq: {
mykey: "myvalue"
}
}
}
})
它给了我
500错误:ER_PARSE_ERROR:您的sql语法有错误;在第1行的“ myvalue” ORDER BY Id LIMIT 1”附近使用正确的语法检查与您的MysqL服务器版本相对应的手册
我也尝试JSON.stringify
对象,但是它根本找不到任何记录。
// Using %% too but didn't work
myRepo.find({
where: {
Data: {
like: `%${JSON.stringfy({
mykey: "myvalue"
})}%`
}
}
})
myRepo.find({
where: {
Data: {
eq: JSON.stringfy({
mykey: "myvalue"
})
}
}
})
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)