Skip to content
Back

Bug: Updating a Document with Relationship Field Only Links First Item - pythonsdk

  • 0
  • Self Hosted
  • Databases
tscheeeek
6 Feb, 2025, 16:33

I’m experiencing an issue when updating a document that contains a relationship_field. Specifically, when I attempt to add multiple relationships to the array, only the first item is successfully linked, while the others remain empty.

TL;DR
Bug in updating a document with a relationship field - when adding multiple relationships, only the first one links successfully while others stay empty. Solution: Instead of passing an array of relationship IDs, try passing a dictionary with each ID mapped to its own key. For example: `data={"cctv_images_incoming": {"id1": True, "id2": True}}`.
tscheeeek
6 Feb, 2025, 16:35
TypeScript
cctv_image_ids = ["id1", "id2"]
databases.update_document(
        APPWRITE_DATABASE_ID,
        APPWRITE_COLLECTIONS_ID_OCCURANCES,
        document_id_to_update,
        data={"cctv_images_incoming": cctv_image_ids},
    )
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