#Need to get the document list data from listDocuments

17 messages · Page 1 of 1 (latest)

wooden cedar
#

Need Help!
I am writing the code below

Client client = FFAppState().appwriteClient;
Databases dbInstance = Databases(client);
DocumentList homesList = await dbInstance.listDocuments(
  databaseId: FFAppConstants.dbInstance,
  collectionId: FFAppConstants.homesCollection,
);
print('homesList => ${homesList.documents}');
return homesList.documents;

I am just getting the Instance not data, when I print it.

wooden cedar
#

@uncut carbon need help

uncut carbon
#

haven't checked the flutter sdk, but what does homesList.documents.toMap() return?

wooden cedar
#

let me try that

wooden cedar
uncut carbon
#

afaik the return value is models.DocumentList and that probably has a .toMap().

#

aah I see, it should probably be homesList.toMap() maybe.

uncut carbon
wooden cedar
wooden cedar
#

Wrote the code below

Client client = FFAppState().appwriteClient;
Databases dbInstance = Databases(client);
DocumentList homesList = await dbInstance.listDocuments(
  databaseId: FFAppConstants.dbInstance,
  collectionId: FFAppConstants.homesCollection,
);
print('homesList => ${homesList.documents.toList()}');
return homesList.documents.toList();

First Pic: Output
Second Pic: homeList
Print statement: homesList => [Instance of 'minified:X0', Instance of 'minified:X0']

uncut carbon
#

I did this -

var databases = Databases(client);
var documents = await databases.listDocuments(databaseId: dbID, collectionId: collectionID);

print(documents.toMap());

the output was correct like this -

{
  "total":1,
  "documents":[
    {
      "$id":xyz,
      "$collectionId":"collectionID",
      "$databaseId":"dbID",
      "$createdAt":"2024-04-09T08":"12":"21.874+00":00,
      "$updatedAt":"2024-04-20T05":"56":"29.516+00":00,
      "$permissions":[],
      "data":{
        "name":"Lorem Ipsum",
        "$id":xyz,
        "$createdAt":"2024-04-09T08":"12":"21.874+00":00,
        "$updatedAt":"2024-04-20T05":"56":"29.516+00":00,
        "$permissions":[],
        "$databaseId":"dbID",
        "$collectionId":"collectionID"
      }
    }
  ]
}
neat phoenix
#

@uncut carbon which appwrite version You are using. me and @wooden cedar are working together on this part but not able to fetch this...We have not tried that toMap() yet byt have tried a lot of thinks ..just for the clarity that which appwrite version and which SDK version of appwrite you are using

uncut carbon
#

Hey @neat phoenix, @wooden cedar 👋
Sorry I was unavailable for a few days so couldn't get back.

I used Cloud x appwrite: ^11.0.1 .

neat phoenix
#

Thanks @uncut carbon ...that toMap() solution is working..thanks 😊