biny01Original post
Web Developer
{
"message": "Invalid query: {"method":"equal","attribute":"accountId","values":["660277c0b25c8e105e95"]}",
"code": 400,
"type": "general_query_invalid",
"version": "0.12.128"
} this is my code export async function getCurrentUser() {
try {
const currentAccount = await getActiveSession();
if (!currentAccount) throw new Error("error getting currentAccount");
console.log(currentAccount, currentAccount.$id);
const currentUser = await database.listDocuments(Databaseid, userid, [
Query.equal("accountId", currentAccount.$id),
]);
console.log(currentUser);
if (!currentUser) throw new Error("error getting current user");
return currentUser.documents[0];
} catch (err) {
console.log(err);
}
}
Summary
Appwrite query not functioning due to an invalid query error. The code is attempting to retrieve a user based on their accountId, but the query structure is incorrect. The error message "Invalid query" with code 400 is appearing. To solve this, modify the query structure to be valid and ensure it matches the database structure.