#Getting error while using Query.equal()

5 messages · Page 1 of 1 (latest)

languid minnow
#

The code snippet is:

export async function getCurrentUser() {
  try {
    const currentAccount = await account.get();

    if(!currentAccount) throw Error;

    const currentUser = await databases.listDocuments(
      appwriteConfig.databaseId,
      appwriteConfig.userCollectionId,
      [Query.equal('accountId', currentAccount.$id)]
    );

    if(!currentUser) throw Error;

    return currentUser.documents[0];
  } catch (error) {
    console.log(error);
  }
}

If I remove Query, it is not showing error.
With Query, it gives error.

Need Help!!

mighty otter
empty dew
#

Same issue after upgrading to 14.0.0
I had to downgrade to 13.0.2
But sadly Query.contains is not supported in this version

polar gate
languid minnow
#

Sorry for late message
Now I got the problem (because of appwrite version).
To correct this issue, I had to write a for loop to solve this problem

for(let i=0;i<currentUser.documents.length;i++) {
      if(currentUser.documents[i].accountId === currentAccount.$id) {
        console.log(currentUser.documents[i]);
        return currentUser.documents[i];
      }
    }

Problem is solved.