Back

How to query key indexes with multiple attributes?

  • 0
  • Web
naveen
28 Apr, 2023, 09:13

api.provider().database.listDocuments(databaseId,collectionId, [Query.equal('lesson',id)],[Query.equal('subject',cat)], ); I used this syntax but it is taking only the first condition and ignoring the second; I have kept an key index containing two attributes lesson and subject but the above syntax throw an error as index not found , so i added subject and lesson as separate index but now it is taking only the first query.

TL;DR
It seems that the provided syntax is not working as expected. To query key indexes with multiple attributes, both queries should be inside an array. For example: ``` api.provider().database.listDocuments(databaseId, collectionId, [ Query.equal('lesson', id), Query.equal('subject', cat) ]); ``` However, it appears that the syntax provided in the question is only taking the first query into account and ignoring the second one. Additionally, the error "index not found" occurred when attempting to use a single index with both attributes. To resolve this, you should create separate key indexes for both 'lesson' and '
Binyamin
28 Apr, 2023, 15:17

I think both queries should be inside on array. Like so

TypeScript
api.provider().database
    .listDocuments(databaseId, collectionId,
        [
            Query.equal('lesson', id),
            Query.equal('subject', cat)
        ]
    );
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