I'm having some trouble with .neq() in my nodejs s...
# help
m
I'm having some trouble with .neq() in my nodejs server, I'm trying to find all users except for a certain user type and I have the query set up with a couple of paramters in there, like a .eq(), and a .gt(), is there a specific order that I have to input these as or am I missing something?
g
I doubt there is any order of queries that matter on way to database and once there Postgres will order them as it thinks best for performance.
m
Okay, thanks for the tip. Any idea why .neq() wouldn’t work? I have the column name in quotation marks, and the string in quotation marks separated by a comma. Is it supposed to be set up different?
g
If you do just that query do you get the right answer?
Also if you have nulls in the field, it will not return those either.
m
yes, if i do just that query i get the correct list of responses, but when I add the other 2 it doesn't seem to work
g
Show all three
Just remember all 3 have to be have be met by some record to be returned (assuming you are chaining them and not putting them in the .or filter)
m
so I have the queries set up as follows: .eq('invitedBy', ${invitedByID in params}) .neq("userType", "partner") .neq('dateSubscribed', 0) if I use the second .neq filter, It comes back correct, if I use the first .neq filter with the .eq filter, it comes back correct, but when i use all 3 it doesn't return anything
the error seems to happen when i use 2 .neq filters. is that not possible?
g
So if I remember my logic that would be NOT(Partner or 0) so you have to have some records that have neither set that way. Unless you have nulls in either then it won't work right. I've not heard of any problem with multiple .neq and postgres supports it.
m
ohhh i see, so it would throw errors if there are some rows with null value in those specific columns?
g
No it will just not include them at all. I was working on a 10 or so optional filter part of my code today, so just stuck in two .neq for "fun" and they worked.
m
Okay, thank you for the tip, I’m going to try that now
So just a quick question, do you mean any null values in the row, or just in each specific column I’m querying through
g
just the query columns .