Skip to content
Back

Query Not Getting Results

  • 0
  • Databases
  • React Native
Don
9 Jun, 2025, 19:17

I am trying to query my collection Categories. Initially, I tried to query by the documentId, but that yielded no results. I then added an index on $id, that did not help... Now tried to Query on the name attribute... that didnt work either. Not sure what I am doing wrong... Here is the query. TIA

config.db, config.collection.categories, [ Query.equal("$id", ["68432b91003a62bcfab4"]) ] );

config.db, config.collection.categories, [ Query.equal("name", ["Emotional Health"]) ]

TL;DR
Developers are trying to query a collection in Appwrite but no results are being displayed. They have tried querying by documentId and name attributes but to no avail. Suggestions to use getDocument method and double-checking query syntax are made. The solution could be to ensure correct attribute and value are used in the Query.equal method.
Axistro
9 Jun, 2025, 19:35

Could you provide the response of rhe function?

Axistro
9 Jun, 2025, 19:36

Also If you are trying tk fetch a document with its id its better to use getDocument

Don
9 Jun, 2025, 19:39

I am getting an empty array ...

Don
9 Jun, 2025, 19:39

I can try that... not sure why I could not get by "name" either... not sure what I am doing wrong ...

Don
9 Jun, 2025, 19:39
Don
9 Jun, 2025, 19:40

printing categories to the console ...

Don
9 Jun, 2025, 19:40

appreciate your time and willingness to take a look. Thank you!

Axistro
9 Jun, 2025, 19:45

Could you go to website and select with the name? Like using filter in your collection?

Don
9 Jun, 2025, 19:46

New to app write... not sure what site you are talking about and where to select...

Axistro
9 Jun, 2025, 19:47

The appwrite website. The page where you see the collection documents

Axistro
9 Jun, 2025, 19:48

There in filters select the attribute(name) and then equal then put the same value

Don
9 Jun, 2025, 19:51

Querey by "name" works with the value entered ...

Axistro
9 Jun, 2025, 19:52

Could you provide the code?

Axistro
9 Jun, 2025, 19:52

Not really sure what is wrong here

Don
9 Jun, 2025, 19:53

try { const { documents, total } = await database.listDocuments( config.db, config.collection.categories, [ Query.equal("name", ["Emotional Health"]) ] ); setCategories(documents); console.log("CATEGORIES RESULT: " + categories); } catch (error) { console.log("ERROR:", error); setError(error); }

Don
9 Jun, 2025, 19:53

the collection has READ permissions for "Any"

Axistro
9 Jun, 2025, 19:54

That is not the problem. If it was related to this then it would return unauthorized error

Don
9 Jun, 2025, 19:54
Axistro
9 Jun, 2025, 19:55

Is listdocument without any query returning any document?

Don
9 Jun, 2025, 19:56

i will try

Don
9 Jun, 2025, 20:00

ok... couple of things ... first... not sure why console.log is not displaying anything...

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