Back

Help in Python SDK Multiple queries

  • 0
  • Self Hosted
firestorm
28 May, 2023, 12:36
TypeScript

        user_id = data["user_id"]
        followed_id = data["followed_id"]
        result=None
        query=[Query.equal("follower",user_id),Query.equal("following",followed_id)]
        try:
            result=databases.list_documents(databaseID,followCollectionID,queries=query)
            print(result)
        except Exception as e:
            print(e)

            result=None```

when i search one by one query it comes but i actually want to search if the collection has a document which satisfies both the queries how can i do that ? 
if i use this syntax i get an index error
TL;DR
TL;DR: User is having trouble creating a query in a Python SDK that searches for a document that satisfies multiple conditions. They currently have a workaround using two separate requests, but are looking for a solution to check if a document exists that satisfies both conditions in a single query. They have provided code for reference. An index error is encountered when trying to implement the solution. No solution is provided in the support thread.
Drake
28 May, 2023, 15:35

What do you mean? You want this?

TypeScript
follower == user id AND following == followed id
firestorm
28 May, 2023, 15:35

Yess i want to see if that exists in the same document

firestorm
28 May, 2023, 15:36

I got a workaround using 2 requests and checking if id matches

Drake
28 May, 2023, 15:36

It should work...whats the result of the API call?

firestorm
28 May, 2023, 15:36

An error index does not exist

firestorm
28 May, 2023, 15:37

But when called individually it comes

Drake
28 May, 2023, 15:37

So...did you create 1 index with both the attributes?

firestorm
28 May, 2023, 15:37

No 2 πŸ€” we had to create one idex with both?

firestorm
28 May, 2023, 15:38

In it

Drake
28 May, 2023, 15:38

Yep!

firestorm
28 May, 2023, 15:38

Let me try that asal

firestorm
28 May, 2023, 15:38

Asap *

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