Back

why when i want to check an array query in my flutter project it doesn't get back any data?

  • 0
  • Databases
  • Flutter
Rovar2000
14 Dec, 2023, 08:25

Query.equal('categoryIds', ['6575abc183a6e1a9189a']) i have a list of categoryIds inside my items When i want to apply the quires by the ids i send it it doesn't retrieve any data back. why does that happen? but when i apply it on name it will bring that data back.

TL;DR
The user is experiencing difficulty retrieving data from an array query in their Flutter project. They mention that queries for relationships are not yet supported, but they have had success using queries with a one-way many-to-one relationship. They suggest trying dummy collections to see if it works. The user also mentions that the query works on a non-array attribute like "name", but not on the "categoryIds" array. They provide a link to a GitHub issue for a potential workaround using full-text search. They also provide an example query: `Query.equal('categoryIds', ['6575abc183a6e1a9189a'])`. No
Ernest
14 Dec, 2023, 10:00

You're already aware from this post that it's currently not supported. The same query works on name precisely because it's not an array (i.e not containing multiple values). You can checkout the linked github issue to find some sort of workaround using full-text search but depending on your use case you may have to go with a different approach. https://discord.com/channels/564160730845151244/1181226010247708813

Ernest
14 Dec, 2023, 10:02

You can also look into appwrite relationships.

Rovar2000
14 Dec, 2023, 11:00

i just looked at the post i didn't realized there was post about it until i searched around. Query Doesn't apply to relationships which is why i separated the categoryIds to a separate Attribute.

Ernest
14 Dec, 2023, 11:12

Yes technically queries are not yet supported for relationships just yet but I'm still able to filter by queries in my flutter project (side project). Admittedly I haven't started using complex queries yet mostly because there are a few headaches/limitations working with relationships so I'm hesitating going all-in on them. I'm able to perform a query like this on a collection with a one-way many-to-one relationship with my users collection and it works. I would recommend you try it with dummy collections and see if it works for you. FYI, there are posts here where some* level of successful queries have been reported.

TypeScript
 queries: [
          Query.equal("user", ["userId"]),
          Query.isNotNull("user"),
          Query.orderDesc("\$createdAt")
        ]);
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