adrianhajdin / healthcare

Build a healthcare platform that streamlines patient registration, appointment scheduling, and medical records, and learn to implement complex forms and SMS notifications.
https://jsmastery.pro
1.81k stars 432 forks source link

Bug Report: Fetching Wrong Documents #33

Open salmansheri opened 1 month ago

salmansheri commented 1 month ago

👟 Reproduction steps

When I try to fetch my appointments documents, it shows some incorrect counts even though the collection is empty

appointmentcollection

My Appointment Collection is empty

My Code:

 const appointments = await databases.listDocuments(
      DATABASE_ID as string, 
      APPOINTMENT_COLLECTION_ID as string, 
      [Query.orderDesc("$createdAt")]

    )

Here I am Fetching my appoitments data but it is showing a fake document

Here I am Logging the count of the document

// Logging the documents length 
    console.log(appointments.documents.length

output:

admin

instead fetching the new documents it fetches and gives old document

👍 Expected behavior

I Need to fetch new document

👎 Actual Behavior

It fetches old document

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Windows

🧱 Your Environment

Nextjs

👀 Have you spent some time to check if this issue has been raised before?

🏢 Have you read the Code of Conduct?

theTechbug commented 3 weeks ago

I will try to fix this issue.

Pheeleex commented 2 days ago

I had a similar issue, i changed [Query.orderDesc("$createdAt")] created at to [Query.orderDesc("$id")]