OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

AppwriteException: Invalid query:

  • Thread starter Thread starter RingMaster
  • Start date Start date
R

RingMaster

Guest
Here I am trying to run this query and it is giving me error. I don't understand why it is a bad request. I am trying to get the specific user from the database using accountId. Please help

This is the function to call the get current user

Code:
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])]
    );
    console.log(currentUser);

    if (!currentUser) throw Error;
    return currentUser.documents[0];
  } catch (error) {
    console.log("from getCurrentUser");
    console.log(error);
  }
}

**this specific line is not executing **

Code:
[Query.equal("accountId", [currentAccount.$id])]

**this is the error ** Error message

this is the response request response with the query

note that without [Query.equal("accountId", [currentAccount.$id])] this line the request is working fine. giving me response of

without the query

please help!

<p>Here I am trying to run this query and it is giving me error. I don't understand why it is a bad request. I am trying to get the specific user from the database using accountId. Please help</p>
<p><strong>This is the function to call the get current user</strong></p>
<pre><code>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])]
);
console.log(currentUser);

if (!currentUser) throw Error;
return currentUser.documents[0];
} catch (error) {
console.log("from getCurrentUser");
console.log(error);
}
}
</code></pre>
<p>**this specific line is not executing **</p>
<pre><code>[Query.equal("accountId", [currentAccount.$id])]
</code></pre>
<p>**this is the error **
<a href="https://i.sstatic.net/iCTPp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iCTPp.png" alt="Error message" /></a></p>
<p><strong>this is the response</strong>
<a href="https://i.sstatic.net/E1sic.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E1sic.png" alt="request response with the query" /></a></p>
<p>note that without [Query.equal("accountId", [currentAccount.$id])] this line the request is working fine. giving me response of</p>
<p><a href="https://i.sstatic.net/tsSZG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tsSZG.png" alt="without the query" /></a></p>
<p>please help!</p>
 

Latest posts

Top