I have a Posts collection with the following schema.
title: String
content: String
isDraft: Boolean
authorId: String<Ref:User>
The authorId is a reference to a record on the Users collection. When fetching a document from the Posts collection, you can select the fields you want to be returned using Query.select([]). If you want to populate the authorId field with data from the Users collection, the only option you have currently is to make a second request which is not performant.
I suggest a new Query method be made to be able to populate fields. Maybe something like Query.populate(fieldToPopulate1, fieldToPopulate2, ...)? My current workaround is using database.getDocument when I need to populate ONE document and databases.listDocuments when I needed to populate multiple documents.
Is there a more performant way for achieving this?
Are you on Appwrite Cloud?
Yes I am
Starting in version 1.3, Appwrite has built in relationship support to do what you mentioned. Cloud, however is on version 1.1.2 so it doesn't have relationship support. We're working on upgrading Cloud
Okay. Thanks for the info.
[SOLVED] Populate fields in response
Recommended threads
- Domain Verification Failed - Fastly Conf...
I am trying to add my subdomain api.getmyself.app to my Custom Domain, but I keep getting the error: Domain 'getmyself.app' is owned by another customer I have...
- Data not loading at the frontend
My App that has been working for weeks, ain't loading anything at the frontend anymore. I thought maybe the API key expired but it's not the case. Users are log...
- Do I need to upgrade my Appwrite plan?
So i am making a file hosting & sharing platform (voltzy.lol) and i am expecting approx 5-8 million visit per month and over 30 million uploads per month do i n...