Back

Query is not defined

  • 0
  • Databases
  • Web
mitsy0_0
3 Jun, 2023, 10:51

I am getting this error Query is not defined, when I try to retrieve the documents I am not sure why, here is my function

TypeScript

            let promise = databases.listDocuments(
                "647ac763cf53edxxxx",
                "647ac820ba38520xxxxx",
                [
                Query.orderDesc("age")
                ]
            );

            promise.then(function (response) {
                console.log(response);
            }, function (error) {
                console.log(error);
            });```
TL;DR
The user is getting a "Query is not defined" error when trying to retrieve documents using the Appwrite API. They have imported the necessary modules correctly. One possible solution to this error is to check if an index has been created for the "age" attribute in the database.
Asutosh
3 Jun, 2023, 11:10

Have you created an index for the age attribute?

mitsy0_0
3 Jun, 2023, 11:14

yes

mitsy0_0
3 Jun, 2023, 11:14

but none of the queries are working

Asutosh
3 Jun, 2023, 11:17

Are you appwrite cloud or its self hosted?

mitsy0_0
3 Jun, 2023, 11:17

cloud

Bouahaza
3 Jun, 2023, 11:18

Do you import Query ?

mitsy0_0
3 Jun, 2023, 11:19

you mean here const { Client, Account, ID, Functions, Databases} = Appwrite;?

mitsy0_0
3 Jun, 2023, 11:21

I imported it now it works

mitsy0_0
3 Jun, 2023, 11:21

thanks๐Ÿ˜…

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