我正在尝试在环回3中使用多个值进行过滤。“ AND条件”不起作用。数值过滤器工作正常,但字符串值不匹配。
这是我现在的状况:
protected constructor(
protected model: Type<T>,
protected activatedRoute: ActivatedRoute,
protected router: Router,
protected service: CrudServiceBase<T>,
private ng7MatBreadcrumbService :Ng7MatBreadcrumbService
) {}
字符串值未推送到数组中。
{ "and": [{ "id": { "neq": "5d146f1f7a62651b8162fcf3" } },
{ "gender": "male" }, { "age": { "between": [16, 60] } },
{ "interestId": { "inq": ["5d11c0ce59e2b64e8dc12956", "5d11c0e259e2b64e8dc12958", "5d11c08659e2b64e8dc12953", "5d11c01759e2b64e8dc1294b", "5d11c03759e2b64e8dc1294d"] } },
{ "location": { "near": { "lat": 26.8574194, "lng": 75.7977288 }, "maxDistance": 6, "unit": "kilometers" } },
{ "maritalStatus": { "like": {} } }, { "college": { "like": {} } },
{ "career": { "like": {} } }, { "currentJob": { "like": {} } },
{ "height": { "between": [50, 89] } }, { "weight": { "between": [72, 192] } }, { "bodyBuild": "Slim" }] }
我不明白哪里是问题。如果我没有传递字符串值,那就很好。
答案 0 :(得分:0)
尝试以下方式:-
if (interestId.highSchool && interestId.highSchool !="") {
query.and.push({
highSchool: {regexp: new RegExp('.*' + interestId.highSchool + '.*', "i")}
})
}