Hi! I have a two-way relationship, 1-1, in appwrite. The two collections are "page" and "metadata". I have just created the new table (metadata table) and added the relationship, so currently, all the values for the relationship in the page table are null + there are no documents in the metadata table (obviously).
But I don't want that. I want that every page has a relationship to metadata. That's why I am currently creating a migration script, and one of the lines look like this:
final metadataResponse = await _database.updateDocument(
databaseId: AppEnv().accommodationDatabaseId,
collectionId: AppEnv().pageCollectionId,
documentId: pageId,
data: {
'metadata': {
'visibleAtCheckIn': false,
'visibleAtCheckOut': false,
'titleImage': null,
},
},
);
Essentially, I create the metadata through the page collection. This works kinda great. It creates the new metadata document, and the metadata attribute in the page table is filled with the id of the newly created metadata. But as already said, I have a two way relationship. The problem is that currently, the "page" attribute in the metadata table is still n/a, even though "metadata" in the page table is filled.
This also does not work:
final metadataResponse = await _database.createDocument(
databaseId: AppEnv().accommodationDatabaseId,
collectionId: AppEnv().pageMetadataCollectionId,
documentId: ID.unique(),
data: {
'visibleAtCheckIn': false,
'visibleAtCheckOut': false,
'titleImage': null,
'page': pageId,
}
As I get this error: TypeError: Instance of 'JSArray<dynamic>': type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>'
So my question is: How can I create the metadata documents and have a bug-free relationship?
Recommended threads
- GB Hours IS NOT resetting
Hi, I was checking my usage and noticed that all of my usage quotas were reset on August 20, 2026, when my billing cycle renewed. Everything else appears to ha...
- Confused about Appwrite Pro pricing
Hi. I've been subscribed to the $25 Appwrite Pro plan, but I've been getting charged $40. I have two projects on my account. I was wondering where exactly the e...
- IMPORTANT! SOC-2 Request Failing
Issue requesting SOC-2. If tried other/private browser as well as filling in optional fields.