1
0
mirror of https://github.com/dstotijn/go-notion.git synced 2025-06-08 23:46:12 +02:00

Fix relation property config types

This commit is contained in:
David Stotijn 2022-08-20 16:13:16 +02:00
parent eebbce29a5
commit 99f28cc1f4
No known key found for this signature in database
GPG Key ID: B23243A9C47CEE2D
2 changed files with 28 additions and 9 deletions

View File

@ -189,9 +189,12 @@ func TestFindDatabaseByID(t *testing.T) {
"type": "relation", "type": "relation",
"relation": { "relation": {
"database_id": "668d797c-76fa-4934-9b05-ad288df2d136", "database_id": "668d797c-76fa-4934-9b05-ad288df2d136",
"type": "dual_property",
"dual_property": {
"synced_property_name": "Related to Test database (Relation Test)", "synced_property_name": "Related to Test database (Relation Test)",
"synced_property_id": "IJi<" "synced_property_id": "IJi<"
} }
}
}, },
"Number of meals": { "Number of meals": {
"id": "Z\\Eh", "id": "Z\\Eh",
@ -327,8 +330,11 @@ func TestFindDatabaseByID(t *testing.T) {
Type: notion.DBPropTypeRelation, Type: notion.DBPropTypeRelation,
Relation: &notion.RelationMetadata{ Relation: &notion.RelationMetadata{
DatabaseID: "668d797c-76fa-4934-9b05-ad288df2d136", DatabaseID: "668d797c-76fa-4934-9b05-ad288df2d136",
SyncedPropName: "Related to Test database (Relation Test)", Type: notion.RelationTypeDualProperty,
DualProperty: &notion.DualPropertyRelation{
SyncedPropID: "IJi<", SyncedPropID: "IJi<",
SyncedPropName: "Related to Test database (Relation Test)",
},
}, },
}, },
"Number of meals": notion.DatabaseProperty{ "Number of meals": notion.DatabaseProperty{

View File

@ -42,8 +42,10 @@ type (
} }
RelationMetadata struct { RelationMetadata struct {
DatabaseID string `json:"database_id,omitempty"` DatabaseID string `json:"database_id,omitempty"`
SyncedPropName string `json:"synced_property_name,omitempty"` Type RelationType `json:"type,omitempty"`
SyncedPropID string `json:"synced_property_id,omitempty"`
SingleProperty *struct{} `json:"single_property,omitempty"`
DualProperty *DualPropertyRelation `json:"dual_property,omitempty"`
} }
RollupMetadata struct { RollupMetadata struct {
RelationPropName string `json:"relation_property_name,omitempty"` 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 ( const (
RollupFunctionCountAll RollupFunction = "count_all" RollupFunctionCountAll RollupFunction = "count_all"
@ -71,6 +81,9 @@ const (
RollupFunctionMax RollupFunction = "max" RollupFunctionMax RollupFunction = "max"
RollupFunctionRange RollupFunction = "range" RollupFunctionRange RollupFunction = "range"
RollupFunctionShowOriginal RollupFunction = "show_original" RollupFunctionShowOriginal RollupFunction = "show_original"
RelationTypeSingleProperty RelationType = "single_property"
RelationTypeDualProperty RelationType = "dual_property"
) )
type SelectOptions struct { type SelectOptions struct {