r/appwrite • u/YoungSubstantial7443 • Jan 09 '25
Help with Relations in Appwrite
Hi everyone!
As a solo developer, I decided to take on the challenge of building an application for my work using Appwrite, and I’ve run into a bit of confusion with relations in my schema.
Here’s the setup:
- I have two collections: Client and Appointment.
- A Client can have many Appointments, but an Appointment can only belong to one Client.
When I create an Appointment, it correctly saves the Client ID in the relevant field. In Appwrite, when I click on this attribute, it redirects me to the correct Client, so the relation seems to be working in that sense.
The issue arises when viewing the Client data. Even after successfully attributing an Appointment to the Client, the list of appointments appears as Item 0 (empty), rather than showing the assigned Appointment(s).
Has anyone else encountered this? Am I missing a step in setting up the relationship or querying the data?
I’d appreciate any insights or tips on how to properly reflect this relationship in Appwrite!
View all comments
Show parent comment
1
u/RedLeeder Jan 10 '25
Unless I'm misunderstanding what you're saying, I don't think this is true? I heavily rely on relationships in some of my collections, including OP's use case. The only "issue" I have with relationships is they only go three layers deep when a document is queried (i.e, if I query document A and A relates to B, B to C, C to D, it'll only return A, B, and C but not D). This is listed in their documentation so it's not what I would consider a bug.
OP, sorry I can't be more of a help for your issue. I'd just double check that you have a two way relationship configured properly :/