Back

[SOLVED] fetch data via listDocuments()

  • 0
  • Databases
  • Flutter
dammy
16 Aug, 2023, 18:43

With the below code, I want to fetch 1.0 without getting a response of Bad: element

TypeScript
dynamic appVersionFetch = await appWriteLogicExtender.databases
          .listDocuments(
              databaseId: "app_data",
              collectionId: "app_version",
              queries: [
            Query.equal('app_version', ["app_version_key"]),
          ]);

      newAppVersion = appVersionFetch.documents.first.data["app_version_id"];
TL;DR
The user was trying to fetch data using the `listDocuments()` function but was receiving a response of "Bad: element." The solution to the problem was to remove the index key from the query and allow it to be used automatically. Additionally, the user should ensure that they pass the correct value in the query instead of just the key. Here is the corrected code: ```dart dynamic appVersionFetch = await appWriteLogicExtender.databases .listDocuments( databaseId: "app_data", collectionId: "app_version", queries: [ Query.equal('app_version', value), ]); new
dammy
16 Aug, 2023, 18:45

this is the indexing pattern used

dammy
16 Aug, 2023, 18:55

fetch data via listDocumenta()

Drake
16 Aug, 2023, 18:56

you don't pass the index key...it's used automatically

Drake
16 Aug, 2023, 18:56

you're supposed to put the value in the query

dammy
16 Aug, 2023, 19:29

okay, that's 1.0 in the query? @Steven

dammy
16 Aug, 2023, 20:27

I appreciate you Sir @Steven

safwan
17 Aug, 2023, 06:31

[SOLVED] fetch data via listDocuments()

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