Skip to content
Back

Relationship lists aren't showing

  • 0
  • 2
  • Self Hosted
  • Flutter
whiskeycron
23 Dec, 2025, 21:38

In flutter, when I perform a listRows function for my table which contains various relationships in addition to normal data, I am not getting the relationships that have lists (i.e many to many), just the ones that have one relationship value (i.e. Many to One). Any thoughts on this? I will post code in the comments.

TL;DR
Issue: Relationship lists are not showing in the app despite fetching the data from tables using Flutter SDK and Appwrite. Solution: The code snippet provided seems to correctly retrieve and process data from Appwrite tables. Possible reasons for the relationship lists not showing could include issues with data mapping or the listRows function implementations. Ensure that the data structure and format match the expected output for displaying relationship lists in the app. Version Info: Appwrite SDK 20.3.0, Self-hosted database version 1.8.0, Flutter version 3.38.5.
whiskeycron
23 Dec, 2025, 21:40

This is my JSON output directly from the row in the appwrite console { "$id": "693bb0330037eb3870ed", "$sequence": 2, "$createdAt": "2025-12-12T06:34:20.279+00:00", "$updatedAt": "2025-12-12T06:34:20.279+00:00", "$permissions": [], "gymId": { "gymName": "My Gym", "website": "mygym.com", "phoneNumber": null, "$id": "693bb0260017d08b390e", "$sequence": 1, "$createdAt": "2025-12-12T06:03:18.281+00:00", "$updatedAt": "2025-12-12T06:33:40.895+00:00", "$permissions": [], "gymManagerId": null, "address": null, "$databaseId": "690acc180012566b56c2", "$tableId": "gyms" }, "boardModerators": [ { "username": "whiskeycron", "igHandle": "", "isPrivate": true, "gradeSystem": "Hueco", "$id": "691205cba21c082802dc", "$sequence": 12, "$createdAt": "2025-12-12T06:35:47.883+00:00", "$updatedAt": "2025-12-12T06:35:47.883+00:00", "$permissions": [], "690adde6002f6541d7d0": "693bb75a003223332215", "$databaseId": "690acc180012566b56c2", "$tableId": "users" } ], "$databaseId": "690acc180012566b56c2", "$tableId": "gymboards" }

whiskeycron
23 Dec, 2025, 21:42

I put this print statement in and get the following results: for (var key in doc.data.keys) { print('Key: $key, Value: ${doc.data[key]}'); }

Results: flutter (28085): Key: $id, Value: 693bb0330037eb3870ed I/flutter (28085): Key: $sequence, Value: 2 I/flutter (28085): Key: $createdAt, Value: 2025-12-12T06:34:20.279+00:00 I/flutter (28085): Key: $updatedAt, Value: 2025-12-12T06:34:20.279+00:00 I/flutter (28085): Key: $permissions, Value: [] I/flutter (28085): Key: gymId, Value: 693bb0260017d08b390e I/flutter (28085): Key: $databaseId, Value: 690acc180012566b56c2 I/flutter (28085): Key: $tableId, Value: gymboards

whiskeycron
23 Dec, 2025, 21:43

As you can see, "gymId" is a relationship and it shows up, but I cannot get "boardModerators" to show up

25 Dec, 2025, 06:39

What is your code, what version of the flutter SDK do you have, and what version of Appwrite do you have?

26 Dec, 2025, 20:04

might not be the best setup, but I have a class that has two subclasses. So I have a table for each and I run this to pull the data using listRows final results = await Future.wait([ AppwriteService.tablesDB.listRows( databaseId: AppwriteDatabases.appwriteDatabaseID, tableId: AppwriteDatabases.boardsTable ), AppwriteService.tablesDB.listRows( databaseId: AppwriteDatabases.appwriteDatabaseID, tableId: AppwriteDatabases.homeBoardsTable ), AppwriteService.tablesDB.listRows( databaseId: AppwriteDatabases.appwriteDatabaseID, tableId: AppwriteDatabases.gymBoardsTable ), ]);

26 Dec, 2025, 20:04

Then it performs this final boardsMap = <String, Map<String, dynamic>>{ for (var doc in results[0].rows) doc.$id: doc.data };

TypeScript
  for (var doc in results[1].rows) {
    final baseData = boardsMap[doc.$id];
    if (baseData != null) {

      final homeboard = HomeBoard(
        boardOwner: doc.data['boardOwner'],
        isPrivate: doc.data['isPrivate'],
        userWhitelist: doc.data['userWhitelist'],
        boardId: doc.$id,
        boardName: baseData['boardName'],
      )
      ..boardAngle = baseData['boardAngle'] ?? 0
      ..dateCreated = DateTime.parse(doc.$createdAt) 
      ..dateSetUpdated = DateTime.parse(doc.$updatedAt);

      if (homeboard.isPrivate &&
          homeboard.isBoardVisible(
            homeboard.userWhitelist,
            homeboard.boardOwner,
            authProvider.currentUser!.$id
          )) {
        tempBoards.add(homeboard);
      } else if (!homeboard.isPrivate) {
        tempBoards.add(homeboard);
      }

      for (var key in doc.data.keys) {
        print('Key: $key, Value: ${doc.data[key]}');
      }
      print('----------');
    }
  }

  for (var doc in results[2].rows) {
    final baseData = boardsMap[doc.$id];
    if (baseData != null) {
      tempBoards.add(GymBoard(
        gymId: doc.data['gymId'],
        boardModerators: doc.data['boardModerators'],
        boardId: doc.$id,
        boardName: baseData['boardName'],
      )
      ..boardAngle = baseData['boardAngle'] ?? 0
      ..dateCreated = DateTime.parse(doc.$createdAt) 
      ..dateSetUpdated = DateTime.parse(doc.$updatedAt)
      );
      for (var key in doc.data.keys) {
        print('Key: $key, Value: ${doc.data[key]}');
      }
      print('----------');
    }
  }
26 Dec, 2025, 20:06

Appwrite SDK 20.3.0, Database self hosted on 1.8.0, Flutter version 3.38.5

26 Dec, 2025, 20:08

heres a screenshot of the columns for the table that I am pulling data from in the results from above

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