Back

Updating associations programmatically via python SDK

  • 0
  • Functions
  • Cloud
Chris Oryschak
11 Mar, 2024, 20:22

I'm trying to update an existing database document's many-to-many assocation via a function but keep getting a Server Error whenever I attempt this code:

TypeScript
def associate_video_to_playlist(playlist_url, video_id):
    playlist_document_id = get_appwrite_playlist_document(playlist_url)['$id']
    video_document = get_appwrite_youtube_video_document(video_id)
    result = documents.update_document(
        APPWRITE_DATABASE_ID,
        YOUTUBE_PLAYLIST_COLLECTION_ID,
        playlist_document_id,
        {
            'youtubeVideo': video_document
        }
    )
    # print(f'playlist document: {playlist_document["youtubeVideo"]}')

    return playlist_document_id

I'm not sure whether to provide the ID of the associated document, the object itself, or what. I've checked permissions for all associated content.

TL;DR
Developers are encountering a `Server Error` when attempting to update a database document's many-to-many association with Python SDK. The issue likely lies in providing the correct type of data (ID versus object) for the association. Double-check the data format being passed in the update operation and ensure permissions are set correctly for all related content.
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