Back

Can't query a specific field using listDocuments

  • 0
  • Databases
  • Apple
  • Cloud
Karbonyth
9 Jun, 2023, 12:25

Hello there,

I'm having what is probably a dumb issue but I haven't been able to figure out what I did wrong:

When using the listDocuments function, I'm able to get all documents from a specific collection, but when I add a query no element is returned. I did check that the value was correct both in the database and the code and I'm guessing I just didn't set-up something properly but I'm just lost right now. I did try to change the index type but no success.

I joined some pictures of the code and the collection setup. Hopefully someone can help me find my missing brain cell ❤️

TL;DR
Issue: The user is unable to query a specific field using the listDocuments function in the Appwrite SDK. When adding a query, no results are returned, even though the value is correct in both the database and the code. Solution: The user discovered that the issue was with using the character "+" in the query string. Removing the "+" allowed the query to work properly.
Binyamin
9 Jun, 2023, 13:00

That seems like it should work.

Can you try it one time like this?

TypeScript
queries: [
  Query.equal("phone_number", [phoneNumber])
]
Karbonyth
9 Jun, 2023, 13:21

Thank you for the suggestion, I did try it before and just re-did it again, but I still have 0 documents returned. 😦 Without the query, my total is 4 as expected, but when added, it's 0. And I can't even count how many times I made sure the value in the query and in the user database phone_number field were identical.

Drake
9 Jun, 2023, 14:18

what did the query print output?

Karbonyth
9 Jun, 2023, 14:22

equal("phone_number", ["string"])

With string being a value that matches the value set in the user present in the collection for the field "phone_number". No whitespace or anything, either from the mobile app or on the database.

Note that this output with the string being in an array is the same wether I put the value in an array myself or not.

Karbonyth
9 Jun, 2023, 14:28

Ho wow I actually just found the issue, maybe I should have started with that: It's not working with the character "+" in the string.

"+3312345678" in the database and the query -> No results "3312345678" in the database and the query -> 1 Result as expected

Karbonyth
9 Jun, 2023, 14:30

Not sure where the issue happens here

Binyamin
9 Jun, 2023, 15:19

This is interesting

Binyamin
9 Jun, 2023, 15:19

Are you running against the cloud or a self-hosted Appwrite instance?

Karbonyth
9 Jun, 2023, 15:50

All on the cloud for now, I'm just trying out stuff and seeing how this SDK works so no fancy stuff 😄

Drake
9 Jun, 2023, 17:08

so i was able to reproduce this on cloud...but not on my local instance (essentially, 1.3.7). I can't see how/where the query value is being modified in the cloud version..

Karbonyth
9 Jun, 2023, 17:16

I guess that at least eliminates a possible parameter encoding issue from the iOS SDK then

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