Back

[SOLVED] NotEqual queries require exactly one value (error 400)

  • 0
  • Databases
punti_z
5 Nov, 2023, 03:34

I am trying to fetch documents from a collection and the query looks like

Query. Equal('Attribute 1', value), Query. Equal('Attribute 2', value2), Query. NotEqual('Attribute 3', List<String values>);

Documentation says it should work. What am I missing ?

TL;DR
The user was getting an error 400 stating that NotEqual queries require exactly one value. They were trying to create a queries array and loop through a document list to add a NotEqual query to the array. Another user pointed out that each query is being AND'd together, so a separate query should be added to the array instead. The user then realized that passing an array makes it an OR condition, which would always be true. The user was trying to fetch documents from a collection using the query Query.NotEqual('Attribute 3', List<String values>), but it was not working. The solution is to provide a single value for
Drake
5 Nov, 2023, 03:37

Passing an array makes it an OR. So you're doing attr3 != val1 OR attr3 != val2 which would always be true

punti_z
5 Nov, 2023, 03:39

Ah you are right, did not think it through. Any way to craft it so its "AND" since the list would be dynamic list of document ids ?

Drake
5 Nov, 2023, 03:40

Every query is AND'd with each other so add a separate query to the queries array

punti_z
5 Nov, 2023, 03:55

Trying something but just so I dont end up wasting too much time on something dumb, I am planning to create a queries array List<String> and loop through document list I dont want and will add a NotEqual query in that queries array. Is that the idea ?

punti_z
5 Nov, 2023, 04:02

Worked .. Thanks

punti_z
5 Nov, 2023, 04:03

[SOLVED] NotEqual queries require exactly one value (error 400)

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more