How to query select only the child collection's id
For example
Vocabulary -> language vocabulary can contain one language
language can belong to many vocabulary
So I want to select only the language id, I do not want to select all attributes of language when I query my vocabulary
Hi - is it just regarding relationships? https://appwrite.io/docs/databases-relationships#query
Yes, it is.
But I think there is a problem on using the Query Select in flutter.
Without using the Query.select
final documents = await databases.listDocuments(
databaseId: kDatabaseId,
collectionId: kVocabularyCollectionId,
queries: [
Query.equal("language", languageSelected.languageId),
]);
Now this is the output:
it contains the language collection's document
But what I want is to select only the language's id
therefore I am using the Query.select,
I try these all code:
Query.select(['language.\$id'])-> not workingQuery.select(['\$id'])-> not workingQuery.select([])-> it is working but weird?
This is the output when I am using the number 3. It is weird right?
currently appwrite gives you every internal attribute always, no matter what you select. With select query, you can specify which YOUR attribute you want to get. But internal ones starting with $, you always get those.
I did not get it Ms. @joeyouss In instance, Vocabulary have relationship in Language Collection. Hence, it is expected when getting those documents in Vocabulary collection, the language collection will be included in payload. Now my question is that, how can I Select query only the id attribute of Language collection.
you can't perform any query filter on relationship field (child) you only can add queries to the parent collection, You can't limit the quantity of items or something similar.
Seems like that queries will be released in the next version
I try these all code:
1. Query.select(['language.\$id']) -> not working
2. Query.select(['\$id']) -> not working
3. Query.select([]) -> it is working but weird?
This 3 filters are acting in the vocabulary collection not in language
Yeah but it is weird without using the Query.select, it gives me the whole data of my language. If I am using the Query.select, it only gives me the id of my language.
🤔
maybe I'm not understanding well but I see all items in the data Map including language, how is before your filter, I see the last image is the output with Query.select([]) but what is the output without it?
this one
I see the difference now, maybe someone of the team can clarify this @Meldiron (sorry to ping you) do you now what could be happen here? it seems like that is working but isn't something documented
Hey there @Mosh Ontong 👋 To answer:
But what I want is to select only the language's id
It seems like a valid concerned, and I opened this to internal discussion. As of Appwrite 1.3.1, inside Query.select, you should only specify your custom attributes. Internal attribudes such as ID, collectionId, databaseId, permissions, createdAt and updatedAt will always be returned.
We noticed this can be annoying and defeat purpose of select query. We initially let those internal attributes there to make offline support possible in future. Thanks to feedback such as yours, we can think about it a bit more to provide better developer experience :appwritepeepo:
Regarding normal select and select with relationships, they should work exactly the same. And for selecting data inside relation, you use . in between names. Sooo in your scenario doing Query.select(['language.$id']) would be the right approach. Again, sadly, this wont work as of right now. Buuut your thread started internal discussion 😇
@Mosh Ontong it would be great if you could create a GitHub issue for this so that the request doesn't get lost and others can 👍🏼 it
[CLOSED] Query Select in relationshiop
Recommended threads
- Cant get realtime working
Hey I nned some help with realtime a gain. I was using client.subscribe(...), and i found out that its depricated then i believe realtime.subscribe(...) is the ...
- Firebase app import
I'm **very** new to appwrite and I just set up appwrite with docker and I'm trying to import a Firebase app I have set up but it's erroring and I don't really k...
- Hi Folks, Database Writing Issue
Hey Folks im trying to get logging setup on my website but im getting an error, i dont have any document id and i think this is the issue but i havent got the f...