From 9d73455a0aed0dba007de08979295fec3d6f5496 Mon Sep 17 00:00:00 2001 From: Arek Mytych Date: Thu, 22 May 2025 14:18:31 +0200 Subject: [PATCH] Add relationship property format - Add a section detailing the format for relationship properties. - Include an example - Add a note about foreign key violation --- docs/content/upsert-items.mdx | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/content/upsert-items.mdx b/docs/content/upsert-items.mdx index e70842c..7b24156 100644 --- a/docs/content/upsert-items.mdx +++ b/docs/content/upsert-items.mdx @@ -46,4 +46,33 @@ Example of property deletion: } ] } -``` \ No newline at end of file +``` + +## Relationship Property Format + +When creating or updating relationship properties, you must provide the explicit +ID of the related item in the `data_value` field. This is different from other +property types that use a direct value. + +Example of a relationship property: +```typescript +{ + "data": [ + { + "id": "stockholm", + "class_id": "City", + "properties": [ + { + "id": "country", + "statements": [ + { "data_value": { "id": "sweden" } } // Reference to the sweden item + ] + } + ] + } + ] +} +``` + +> **Note:** If the referenced item doesn't exist in the database, a foreign key +violation error will be raised. \ No newline at end of file