Back

[SOLVED] listDocuments with relationship

  • 0
  • Web
sokratesli
30 Sep, 2023, 12:41

Hello

How can I output to a list from a collection including the relationship to another collection and output these values as well.

Thank you

ex.

` let promise = databases.listDocuments( DB_ID, COLLECTION_ID_PEOPLE, COLLECTION_ID_RECORDS, [ Query.select(["PEOPLE.firstName", "PEOPLE.lastName"], ["RECORDS.title", "RECORDS.text"]) ] );

promise.then(function (response) { console.log(response); }, function (error) { console.log(error); });`

TL;DR
The user wants to output a list from a collection including the relationship to another collection. They provided an example code but were unsure if it would work. Another user confirmed that the provided code would work.
Guille
30 Sep, 2023, 20:08

If you are using relationship, you'll always get the relate docs, at the moment you can't query relationship (not supported)

sumerokr
11 Oct, 2023, 19:52

I have just tried that and it works! Something like

TypeScript
const books = await databases.listDocuments('db_id', 'coll_id', [
  Query.select(['title', 'author.name'])
]);
Drake
14 Oct, 2023, 23:06

[SOLVED] listDocuments with relationship

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