Back

Query with relationship

  • 0
  • Self Hosted
  • Databases
  • Web
BeT
6 Mar, 2024, 16:47

So i have this database with collections user > topic > notes. Each user can have multiple topics and each topic can contain many notes. if I get user document with no queries, it fetches all of his topics and notes which I think might be slow if he has many notes. I've tried to use select query like so Query.select(['topic.*']). It doesn't return notes but also doesn't return $id of the topic document so I could get notes related to that topic. what would be the best practice here?

TL;DR
Developers want to query relationships in a database with collections of users, topics, and notes efficiently. They are currently unable to fetch topic documents along with their associated notes. One suggestion is to add a userId attribute to the topic collection as a reference. This way, developers can query the topic document and then fetch notes related to that specific topic using the userId.
darShan
6 Mar, 2024, 16:53

Queries with relationships aren't supported atm.

darShan
6 Mar, 2024, 16:53

maybe you could add userId attribute to the topic collection and use it as a reference via the user id.

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