我的数据有一个数组,其中每个对象都包含状态,我需要从该值进行过滤。
我的数据如下,
"npi" : [
{
"npi" : "1013987536",
"xm_score" : 70.3,
"state" : "TX",
"zip" : "78026",
"lat" : 28.918592,
"lon" : -98.54152,
"specialty" : [
"x065",
"x109"
]
},
{
"npi" : "1023010527",
"xm_score" : 70.0,
"state" : "MA",
"zip" : "02120",
"lat" : 42.32918979,
"lon" : -71.10625722,
"specialty" : [
"x065",
"x109"
]
},
{
"npi" : "1033116371",
"xm_score" : 70.9,
"state" : "TN",
"zip" : "37207",
"lat" : 36.222188,
"lon" : -86.773002,
"specialty" : [
"x067"
]
},
{
"npi" : "1053435198",
"xm_score" : 71.0,
"state" : "KS",
"zip" : "66160",
"lat" : 39.05615308,
"lon" : -94.61062748,
"specialty" : [
"x096",
"x067"
]
}]
我需要为各州进行搜索,
var modelObj = {'npi': []};
if (state) {
modelObj.npi.state = state;
}
match.find(modelObj).limit(10).exec(function(err,data) {
callback(null, data);
});
这是我尝试的但是这对我来说真的没有用。有人请建议我帮忙。谢谢。