
Normal Output:
"questions": {
"total": 2,
"documents": [
{
"order": 1,
"$id": "quiz_question_1",
"questionId": {
"$id": "question_1",
"$databaseId": "...",
"$collectionId": "..."
}
},
{
"order": 2,
"$id": "quiz_question_2",
"questionId": {
"$id": "question_2",
"$databaseId": "...",
"$collectionId": "..."
}
}
]
}
but if i do
Query.select(["question", "order"]);
it throws an error
AppwriteException: Cannot select attributes: questionId
code: 400,
type: 'general_query_invalid',
response: {
message: 'Cannot select attributes: questionId',
code: 400,
type: 'general_query_invalid',
version: '1.6.0'
}

sorry for typo: the query was
Query.select(["questionId", "order"]);

The issue seems to arise from attempting to select nested attributes, such as questionId

Since Query.select
isn't able to handle nested attributes directly,

You can work around this by fetching the entire document and then extracting the specific fields you need in your application logic.

const response = await database.listDocuments("<DATABASE_ID>", "<COLLECTION_ID>");
const documents = response.documents.map(doc => ({
order: doc.order,
questionId: doc.questionId
}));
console.log(documents);

This way, you get all the necessary data and then filter out the required attributes
.


thank you @Guri
Recommended threads
- Creating a relationship with nested obje...
{ "data": { "name": "DiDi", "type": "Software Development", "userJobs": [{ "$id": "68cbf1e2003612fb13ca", "j...
- Realtime integration with SSR auth
Hey, I have a nextjs website with SSR auth, works great. I use a session client for user verification and an admin client with API key. Both is used with node-...
- Adding "name" column to table creates 2-...
As stated, im adding the "name" column to one table, it adds 4 duplicates. In another table it adds 3 duplicates, and when I delete 1 of them, all duplucates di...
