You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rest filter problems with undefined model entries. #1573
I'm working on a project and try to write a search mask for emails.
I was a little confused while I was testing it, because of the output from the rest filter option:
That's right:
/api/companies?where[or][0][mail][like]=a --> returns all items with a 'a' in it
That's acceptable:
/api/companies?where[or][0][mail][like]=undefined --> returnes all, items without a defined mail
Confused by this:
/api/companies?where[or][0][mail][like]=u --> returnes all, items without a defined mail
/api/companies?where[or][0][mail][like]=.de --> returnes all, items without a defined mail
Can you help me please to make it possible to search for email endings (.de)
Thank's for your quick reply.
I took the where without the filter[] because this didn't work in companies/count? ...
I changed the code to match exactly your convention and the problem still exists. It still doesn't work.
BTW, this is my full request: http://localhost:3000/api/companies
?filter[where][and][0][team]=1
&filter[where][or][1][name][like]=.de
&filter[where][or][2][mail][like]=.de
&filter[order]=nameDESC
&filter[limit]=10
&filter[skip]=0
I think the problem is: If text is missing it is declared as "undefined" and because of that the filter will return all undefined fields when I search for a subset of the word undefined.
Yes I'm searching for this: team === '1' && (name like '.de' || mail like '.de')
I try to make an example:
If I type in my search mask the letters "de" I want to get results where "de" is find in
The name and
The mailadress.
My Problem: If I type in "de" it shows me names and emailadresses with this letters in it but it also shows me e.g. id 1 (see below) because there is no email adress (the adress is undefined). Because of undefined I get this wrong result [1,2,3] instead of the right result [2,3].
I try to get this: team === '1' && ((name like '.de' && name nlike undefined) || (mail like '.de'&& mail nlike undefined))
Activity
[-]Rest filter problems with undefined model entries.[/-][+]Rest filter problems with undefined model entries. bug[/+][-]Rest filter problems with undefined model entries. bug[/-][+]Rest filter problems with undefined model entries.[/+]raymondfeng commentedon Aug 7, 2015
You should use the following convention:
http://localhost:3000/api/notes?filter[where][or][0][mail][like]=.de
A less confusing way (using stringfied json) is:
http://localhost:3000/api/notes?filter={"where":{"or":[{"mail":{"like":".de"}}]}}
BTW, you don't need to use "or" in this case.
cleaner321 commentedon Aug 7, 2015
Thank's for your quick reply.
I took the where without the filter[] because this didn't work in companies/count? ...
I changed the code to match exactly your convention and the problem still exists. It still doesn't work.
BTW, this is my full request:
http://localhost:3000/api/companies
?filter[where][and][0][team]=1
&filter[where][or][1][name][like]=.de
&filter[where][or][2][mail][like]=.de
&filter[order]=nameDESC
&filter[limit]=10
&filter[skip]=0
I think the problem is: If text is missing it is declared as "undefined" and because of that the filter will return all undefined fields when I search for a subset of the word undefined.
raymondfeng commentedon Aug 7, 2015
count()takes thewhereargument instead offilter.order):Do you want to find companies with
team === '1' && (name like '.de' || mail like '.de')?cleaner321 commentedon Aug 7, 2015
Yes I'm searching for this:
team === '1' && (name like '.de' || mail like '.de')I try to make an example:
If I type in my search mask the letters "de" I want to get results where "de" is find in
My Problem: If I type in "de" it shows me names and emailadresses with this letters in it but it also shows me e.g. id 1 (see below) because there is no email adress (the adress is undefined). Because of undefined I get this wrong result [1,2,3] instead of the right result [2,3].
I try to get this:
team === '1' && ((name like '.de' && name nlike undefined) || (mail like '.de'&& mail nlike undefined))Example entries:
{
"id": "1",
"name": "Raymond Feng",
"createdAt": "2015-08-07T18:55:22.556Z",
"updatedAt": "2015-08-07T18:55:22.556Z"
},
{
"id": "2",
"name": "cleaner321",
"email": "foo@bar.de",
"createdAt": "2015-08-07T18:56:18.719Z",
"updatedAt": "2015-08-07T18:56:18.719Z"
},
{
"id": "3",
"name": "Dennis",
"email": "foo@bar.com",
"createdAt": "2015-08-07T18:56:18.719Z",
"updatedAt": "2015-08-07T18:56:18.719Z"
}