Back

Error when trying to fetch a document with relationship query

  • 0
  • Self Hosted
  • Databases
Mr. Bakbuki
15 Mar, 2024, 13:23

This code works fine:

TypeScript
const doc = await databases.getDocument("main", "users", account.$id, [
    Query.select(["premium"]),
  ]);

But this code throws an error:

TypeScript
const doc = await databases.getDocument("main", "users", account.$id, [
    Query.select(["premium", "albums"]),
  ]);
``` where "albums" is a relationship attribute

The error:
```json
{
  "code": 500,
  "type": "general_unknown",
  "response": {
    "message": "Server Error",
    "code": 500,
    "type": "general_unknown",
    "version": "1.5.3"
  }
}

And in the logs:

TypeScript
[Error] Method: GET
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
[Error] Type: Utopia\Database\Exception
[Error] Message: Cannot select attributes: albums
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php
[Error] Line: 5249
TL;DR
Error occurs when trying to fetch a document with a relationship query including the "albums" attribute. Server throws a 500 error indicating "Cannot select attributes: albums".Relationship query attribute causes server error.
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