From 99f28cc1f490c4fd16fc41cfc8cc8c1a134dd07b Mon Sep 17 00:00:00 2001 From: David Stotijn Date: Sat, 20 Aug 2022 16:13:16 +0200 Subject: [PATCH] Fix relation property config types --- client_test.go | 16 +++++++++++----- database.go | 21 +++++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/client_test.go b/client_test.go index e449745..d3439dd 100644 --- a/client_test.go +++ b/client_test.go @@ -189,8 +189,11 @@ func TestFindDatabaseByID(t *testing.T) { "type": "relation", "relation": { "database_id": "668d797c-76fa-4934-9b05-ad288df2d136", - "synced_property_name": "Related to Test database (Relation Test)", - "synced_property_id": "IJi<" + "type": "dual_property", + "dual_property": { + "synced_property_name": "Related to Test database (Relation Test)", + "synced_property_id": "IJi<" + } } }, "Number of meals": { @@ -326,9 +329,12 @@ func TestFindDatabaseByID(t *testing.T) { ID: "lV]M", Type: notion.DBPropTypeRelation, Relation: ¬ion.RelationMetadata{ - DatabaseID: "668d797c-76fa-4934-9b05-ad288df2d136", - SyncedPropName: "Related to Test database (Relation Test)", - SyncedPropID: "IJi<", + DatabaseID: "668d797c-76fa-4934-9b05-ad288df2d136", + Type: notion.RelationTypeDualProperty, + DualProperty: ¬ion.DualPropertyRelation{ + SyncedPropID: "IJi<", + SyncedPropName: "Related to Test database (Relation Test)", + }, }, }, "Number of meals": notion.DatabaseProperty{ diff --git a/database.go b/database.go index 0cb84a0..2fe8106 100644 --- a/database.go +++ b/database.go @@ -41,9 +41,11 @@ type ( Expression string `json:"expression"` } RelationMetadata struct { - DatabaseID string `json:"database_id,omitempty"` - SyncedPropName string `json:"synced_property_name,omitempty"` - SyncedPropID string `json:"synced_property_id,omitempty"` + DatabaseID string `json:"database_id,omitempty"` + Type RelationType `json:"type,omitempty"` + + SingleProperty *struct{} `json:"single_property,omitempty"` + DualProperty *DualPropertyRelation `json:"dual_property,omitempty"` } RollupMetadata struct { RelationPropName string `json:"relation_property_name,omitempty"` @@ -54,7 +56,15 @@ type ( } ) -type RollupFunction string +type DualPropertyRelation struct { + SyncedPropID string `json:"synced_property_id,omitempty"` + SyncedPropName string `json:"synced_property_name,omitempty"` +} + +type ( + RollupFunction string + RelationType string +) const ( RollupFunctionCountAll RollupFunction = "count_all" @@ -71,6 +81,9 @@ const ( RollupFunctionMax RollupFunction = "max" RollupFunctionRange RollupFunction = "range" RollupFunctionShowOriginal RollupFunction = "show_original" + + RelationTypeSingleProperty RelationType = "single_property" + RelationTypeDualProperty RelationType = "dual_property" ) type SelectOptions struct {