Babyo7_
27 Jun, 2024, 13:43

can we sort the relationship on basis of updated , basically i have a user collection having relation with imagescollection any waey to get images when calling user collection as imaeg to be sort on basis of updated?

TL;DR
Developers discussing optimizing queries in an application to fetch only necessary data and speed up the process. They recommend using Query.select, adding a userId attribute to the image collection, and possibly implementing doc-level permissions. They also consider sorting the relationship based on the 'updated' attribute in the user collection.
darShan
27 Jun, 2024, 13:47

So, you want the image relationship sorted when fetching a user document too? Just trying to understand the usecase. One user can have many images?

Babyo7_
27 Jun, 2024, 13:48

hm

darShan
27 Jun, 2024, 13:50

but i dont think thats really possible with queries too. fetching a user doc will fetch all the images i think (or max of 25?). What you could do is maybe add a userId attribute to the image collection & fetch those with Query.

darShan
27 Jun, 2024, 13:50

possibly also add a doc level permission

Babyo7_
27 Jun, 2024, 13:52

yeah i think have to do two fetch user and other images

darShan
27 Jun, 2024, 13:53

you can use Query.select and not add the relationship data attribute key to avoid fetching that. A bit quicker and faster to get only the data required. After that fetch the images with your Query for userId and limit & orderDesc

Babyo7_
27 Jun, 2024, 13:55

hm! thanks buddy

darShan
27 Jun, 2024, 13:58

no worries. pl. mark the issue as [SOLVED] if the issue/question is resolved.

Happy Appwriting :appwritecheers:.

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