我已将JSON数据存储在表中 . 我想基于userId获取数据,userId是Users Object的属性 .
示例:如果用户包含513,我想获取所有记录
我的表数据样本:
Table name:share
Id name sharedusers
1 xxxx {"accessType":0,"permission":"1","specificUsers":
[{"users":"502,512,513","permission":"1"}]}
2 yyy {"accessType":0,"permission":"1","specificUsers":
[{"users":"47,52,60","permission":"1"}]}
3 zzzz {"accessType":0,"permission":"1","specificUsers":
[{"users":"502,512,513","permission":"1"}]}
我尝试在find()方法中执行以下查询但是不起作用,它显示错误..
{"where": {"sharedusers": {"regexp": "/"users":"[^"]*\b513\b/"}}}
{"where": {"sharedusers": {"regexp": /"users":"[^"]*\b513\b/
}}}
{"where": {"sharedusers": /"users":"[^"]*\b513\b/} }
{"where": {"sharedusers": "/"users":"[^"]*\b513\b/"} }
and also i tried restcall
filter[where][share][regexp]=/"users":"[^"]*\b513\b/
在MySql中我尝试了以下代码,它的工作正常但是我不知道如何在strongloop中做同样的事情 .
SELECT * FROM share where sharedusers REGEXP '"users":"[^"]*[[:<:>:]]';
我的模型定义:
{
"name": "share",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string"
},
"sharedusers": {
"type": "string"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
Mysql版本:'5.6.27-log'