Back

Searching Docs using Relationship Attributes

  • 0
  • Databases
  • Web
Vishal Lohar
23 Dec, 2023, 03:48

Hi, I have a posts collection with few relationship attributes like Categories, Tags, and Author. Now I want to fetch posts of specific Author, Tags, Or Categories. Is this possible? And also use other features like Appwrite Queries.

TL;DR
User wants to fetch posts from a collection based on specific author, tags, or categories using Appwrite Queries. They also want to use other features like the select query to exclude certain attributes. However, queries on relationships are not currently supported. User suggests using two-way relationships and a select query to avoid using relationship attributes where not required. Solution: Currently, queries on relationships are not supported in Appwrite. User can consider using two-way relationships and a select query to achieve their desired result.
Drake
23 Dec, 2023, 19:17

Queries on relationships are not supported.

Vishal Lohar
25 Dec, 2023, 02:57

Okay. Then how can I do what I want to do? If i don't use relationships then displaying all posts in backend will be difficult. After fetching all posts I have to loop all documents and make multiple fetch requests. Adds a lot of latency and it is not a good experience for both dev and client.

Drake
25 Dec, 2023, 03:55

I don't think additional queries are that bad. That said, if you really need to query on categories, tags, and author, I would maybe include the author name, and a string for categories and a string for tags. Then, id use the search query

Vishal Lohar
25 Dec, 2023, 09:05

Okay. I will test it

Vishal Lohar
25 Dec, 2023, 09:05

Anyway. Is it possible to use Appwrite select query to not return just one attribute? E,g: select("-title")

Vishal Lohar
25 Dec, 2023, 09:07

If there is, then I can use two-way relationship and avoid relationship attributes where not required using the select query.

Vishal Lohar
25 Dec, 2023, 09:07

Even this will not allow me to do pagination and run queries on posts relationship attribute of tags collection. But this is what i can think of

Drake
26 Dec, 2023, 01:52

No

Drake
26 Dec, 2023, 01:52

No, because queries on relationships are not supported

Vishal Lohar
26 Dec, 2023, 03:16

Okay. I hope small and important features like this get added to Appwrite ASAP. E.g - Upsert documents and Queries on Relationship

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