Back

[Help] How to overcome 3 level nesting limit in relationship?

  • 0
  • Databases
  • Flutter
FiestyCushion
30 Apr, 2023, 04:34

I want to be able to access 4th child of a main object that are in a relationship. I am able to retrieve upto the third child. I read the docs and there it stated that the relationship were limited upto 3 level nesting but I was wondering if there is a way to overcome this??

TL;DR
The user is asking if there is a way to overcome the 3 level nesting limit in relationships. It seems that there is no solution provided in the thread.
hortigado
30 Apr, 2023, 06:26

Hello, I make a listdocuments call to get the 4 document with the $id of its parent and then I update the state with the document obtained

FiestyCushion
30 Apr, 2023, 11:52

I don't think that worked.

FiestyCushion
30 Apr, 2023, 11:53
TypeScript
{
    "total": 1,
    "documents": [
        {
            "year": "020",
            "department": "cse",
            "group": "ab",
            "$id": "644bc5e99e493ea3b6e6",
            "$createdAt": "2023-04-28T13:11:05.649+00:00",
            "$updatedAt": "2023-04-29T10:09:47.482+00:00",
            "$permissions": [],
            "semester": [
                {
                    "name": "fifth",
                    "$id": "644bc5e0e205c327a4f6",
                    "$createdAt": "2023-04-28T13:10:56.926+00:00",
                    "$updatedAt": "2023-04-29T10:09:47.494+00:00",
                    "$permissions": [],
                    "routine": [
                        {
                            "weekDay": "sunday",
                            "$id": "644bc5d31eab2e562140",
                            "$createdAt": "2023-04-28T13:10:43.126+00:00",
                            "$updatedAt": "2023-04-29T10:09:47.510+00:00",
                            "$permissions": [],
                            "$databaseId": "6447916e7fd0bb75c420",
                            "$collectionId": "644bc4d36be4d59b861c"
                        }
                    ],
                    "$databaseId": "6447916e7fd0bb75c420",
                    "$collectionId": "644bc4c64c253bb83009"
                }
            ],
            "$databaseId": "6447916e7fd0bb75c420",
            "$collectionId": "644bc49a8f923016fd61"
        }
    ]
}
FiestyCushion
30 Apr, 2023, 11:53

i have the relations setup as Class -> Semester -> Routine -> Period

FiestyCushion
30 Apr, 2023, 11:56

Is there an image i can rollback to when it wasn't deprecated?

hortigado
30 Apr, 2023, 14:46

yes work for me

hortigado
30 Apr, 2023, 14:46

` static Future<CerdosModel?> getByCamada(String id) async { try { DocumentList json = await databases.listDocuments( databaseId: AppWrite.dbId, collectionId: AppWrite.cerdosCollectionId, queries: [ Query.equal("camadas", id), ], );

TypeScript
  return CerdosModel.fromJson(json.documents.first.data);
} catch (e) {
  return null;
}

}`

hortigado
30 Apr, 2023, 14:47

` CerdosModel? cerdos = await CerdosEndpoint.getByCamada(camada.$id!); camada.cerdos!.add(cerdos!); cerdos.camadas = camada;

TypeScript
pecerasController.peceras
    .firstWhere((element) => element.$id == cerdos.corralesEngorde!.$id)
    .cerdos!
    .first = cerdos;`
hortigado
30 Apr, 2023, 14:47

Example with getx

hortigado
30 Apr, 2023, 14:49

Im obtain the 4th document "cerdos" with $id of the document 3 "camadas"

Drake
30 Apr, 2023, 15:14

Not really. The limit was always supposed to be 3

FiestyCushion
30 Apr, 2023, 15:14

isnt 3 like too low??

Drake
30 Apr, 2023, 15:15

I don't think so 🤷‍♂️

FiestyCushion
30 Apr, 2023, 15:15

aight fair

FiestyCushion
30 Apr, 2023, 15:15

but is there a way to tackle it

Drake
30 Apr, 2023, 15:16

You can tweak the code. Or change your client side code to fetch the necessary related data

FiestyCushion
30 Apr, 2023, 15:20

or should i use queries lile hortigado suggested?

Drake
30 Apr, 2023, 15:21

That was my 2nd suggestion

FiestyCushion
30 Apr, 2023, 15:22

I will try that then Thanks for your help🤗

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