I am having a database with collections as : Countries, Categories, SubCategories, Posts
My posts collection has attributes as: countryID, categoryID, subCategoryID, title, Image, content
Now if I have to query a list of posts it returns data like {[{'countryID': 'countryUniqueID','categoryID' : 'categoryUniqueID', 'subCategoryID': 'subCategoryUniqueID', 'title': 'Post Title', 'content': 'post content ......' },...]}
Here I got id's for country, category and sub category. Instead of getting id's I want to get names for them. NOTE: I don't wanna use relationships as they are experimental and I am working on a realtime production ready application. What are the other alternatives for getting desired results.
is there anyone who knows about this?
The only way to get the names in the response direct from Appwrite would be to either store the names in the collections, or with Relationships
Your only other option is to take the response you’re currently getting and make new requests for each of those IDs
If you don’t want to do that on the client side, you could put it into a Function
I think using direct names is not a good practice. Relationships are not mature yet. And the third one using functions is okey but is not it a bad practice to query for every id means i have to loop the list of post documents and for every post again i run queries to get data from other collections is not it a bad one
Of course, none of the options are ideal - but there isn't any other way currently, I'm afraid. This is exactly what Relationships was created for, but if you don't want to use them yet, you don't really have many other options
The reason for not choosing relationships is that they don't support queries and also they are still experimental.
Please if someone knows about when we can expect the relationships to be fully stable. Because they are the backbone of any live app.
Anyone from core team, please throw some light on this issue. Because its a biggest nightmare for our team.
i can't say when exactly. probably not for a (minor) release or 2. it all depends on whether we find more bugs.
for now, i would recommend manually handling the relationships yourself by fetching the related documents after fetching from the primary collection.
after fetching the related collections, i highly recommend convering the response to a hash where the key is the ID and the value is the document. This will allow you to quickly look up the related document when you're iterating over your primary collection.
for example:
Thank you @Steven. One more thing, Should we create server side functions or achieve it simply through client side. Which one is best optimized for appwrite.
Kindly add it to closest roadmap. And please also share the link if any for upcoming updares/changes in appwrite. So that we can directly track and vote for features.
I would just do it client side
We don't have a public roadmap yet...we're still figuring that out
[SOLVED] Querying data from a collection that depends on other collections!
Recommended threads
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.