Skip to content
Back

Order query not working

  • 0
  • Web
Aks8796
16 Jul, 2024, 11:37

When sorting data based on $createdAt in descending order, I get an empty array.

Node-appwrite version = ^13.0.0

TypeScript
      DATABASE_ID!,
      APPOINTMENT_COLLECTION_ID!,
      [Query.orderDesc("$createdAt")]
    );
TL;DR
Issue: Empty array received when sorting data based on `$createdAt` in descending order. Solution: Modify the code to specify the field name correctly. Corrected code: ``` const appointments = await databases.listDocuments( DATABASE_ID!, APPOINTMENT_COLLECTION_ID!, [Query.orderDesc("createdAt")] ); ```
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