Skip to content
Back

Issue in fetching documents from database

  • 0
  • Databases
Taussy10
19 May, 2025, 14:32

So, I'm trying to fetch the data from database and for some reason I'm seeing different things in console by returning promise I'm getting: [[object]] and by returning promise.document I'm getting [array] why ? You can see in chapters key in both the images

TL;DR
Issue with fetching documents from the database. Returned data is not consistent when logging `promise` vs `promise.documents`. Check if a relation is being used and log separately if so. The data is displayed differently in the console, with `[array]` shown when retrieving `promise.document` and `[[object]]` shown for `promise`. This inconsistency is evident in the chapters key of both data representations. Solution: The issue arises from logging the `promise` object which likely includes nested objects. To access the data in `promise.documents`, focus directly on that property for consistent output.
Axistro
19 May, 2025, 14:37

Using relation? If yes You would have to console log separately

Darshan Pandya
19 May, 2025, 14:49

promise is a DocumentList which includes the docs and a total property. an Object. promise.documents is an array of Documents.

do a console.log(JSON.stringify(promise, null, 4)); to see a prettified data.

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