Back

appwrite query isnt working properly am facing this problem

  • 0
  • Databases
  • Web
biny01
26 Mar, 2024, 07:39

{ "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();

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

TL;DR
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.
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