Back

appwrite exception: invalid query

  • 0
  • Databases
Trufaux
16 Mar, 2024, 01:52

I'm getting the error:

AppwriteException: Invalid query: {"method":"equal","attribute":"accountId","values":["XXXXXXXXXXXXXXX"]} I believe this is the errant code:

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

TypeScript
  return currentAccount;
} catch (error) {
  console.log(error);
}

}

export async function getCurrentUser() { try { const currentAccount = await getAccount();

TypeScript
    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);
}

}`

Thanks in advance for any assistance.

TL;DR
Issue: An AppwriteException is thrown with the error "Invalid query" in the app's code. Solution: The error stems from the query in the `getCurrentUser` function where the accountId filter isn't being set correctly. Check the query parameters and ensure that the `accountId` filter is being passed correctly.
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