I have a collection that has attribute named ids of type arrays , in ids some id will be store that will belong to it , i want to query this collection such that only that documents fetch in which any specific id containes in ids attribute , i will paas this id in input , how will i do that in react.
You can achieve that by creating another field named search and add fullText index to it
Then add all the ID's to that field seperate by space.
If I understood well you need to create a key index and use Query.equal('ids' ['id1', 'id2', '...'])
@Binyamin Why you prefer fullText? 🤔
Because I though he also liked to perform a search to find only one ID
If the match looking is for all the IDs together then your solution is the right one.
Yes, the description is not very clear, lets wait until he clarify what he is looking for
"title": String ,
"ids": Array[String],
amount: Int
)```
so when i pass any id in function , all document that contains this id in ids array should get
const queries = [Query.equal('ids', [...])]
const response = await databases.listDocuments('DATABASE_ID', 'COLLECTION_ID', queries);
This is what you should do with the JS SDK
its not working
try {
const queries = [Query.equal('ids', [id])]
return database.listDocuments(databaseID,
collectionId,
queries
);
} catch (e) {
console.error(e.message);
}
};```
Do you get any error, or you just get an empty array?
Does your collection or document have the correct permission?
i got empty array
My collection has proper permission , and indexing also
Please check this, issue: https://github.com/appwrite/appwrite/issues/2838
it seems like is not officially supported however the last comment says you can use Query.search
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 ...
- 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...
- Middleware
how to make middleware in nextjs appwrite with client side auth?