Repository: jomei/notionapi
Pull request #113 (2022-09-16 13:07:49)

Added missing fields for Database object

jomei: 🔥 

Patch:
diff --git a/database.go b/database.go
index 7542cfe..e729c48 100644
--- a/database.go
+++ b/database.go
@@ -124,7 +124,12 @@ type Database struct {
 	Parent         Parent     `json:"parent"`
 	URL            string     `json:"url"`
 	// Properties is a map of property configurations that defines what Page.Properties each page of the database can use
-	Properties PropertyConfigs `json:"properties"`
+	Properties  PropertyConfigs `json:"properties"`
+	Description []RichText      `json:"description"`
+	IsInline    bool            `json:"is_inline"`
+	Archived    bool            `json:"archived"`
+	Icon        *Icon           `json:"icon,omitempty"`
+	Cover       *Image          `json:"cover,omitempty"`
 }
 
 func (db *Database) GetObject() ObjectType {


Test patch:
diff --git a/database_test.go b/database_test.go
index 75765ca..db44134 100644
--- a/database_test.go
+++ b/database_test.go
@@ -16,6 +16,8 @@ func TestDatabaseClient(t *testing.T) {
 		t.Fatal(err)
 	}
 
+	emoji := notionapi.Emoji("🎉")
+
 	var user = notionapi.User{
 		Object: "user",
 		ID:     "some_id",
@@ -204,6 +206,19 @@ func TestDatabaseClient(t *testing.T) {
 							Text: &notionapi.Text{Content: "patch"},
 						},
 					},
+					Description: []notionapi.RichText{},
+					IsInline:    false,
+					Archived:    false,
+					Icon: &notionapi.Icon{
+						Type:  "emoji",
+						Emoji: &emoji,
+					},
+					Cover: &notionapi.Image{
+						Type: "external",
+						External: &notionapi.FileObject{
+							URL: "https://website.domain/images/image.png",
+						},
+					},
 				},
 			},
 		}
@@ -276,6 +291,19 @@ func TestDatabaseClient(t *testing.T) {
 							Annotations: &notionapi.Annotations{Color: notionapi.ColorDefault},
 						},
 					},
+					Description: []notionapi.RichText{},
+					IsInline:    false,
+					Archived:    false,
+					Icon: &notionapi.Icon{
+						Type:  "emoji",
+						Emoji: &emoji,
+					},
+					Cover: &notionapi.Image{
+						Type: "external",
+						External: &notionapi.FileObject{
+							URL: "https://website.domain/images/image.png",
+						},
+					},
 				},
 			},
 			{
@@ -318,6 +346,19 @@ func TestDatabaseClient(t *testing.T) {
 							Annotations: &notionapi.Annotations{Color: notionapi.ColorDefault},
 						},
 					},
+					Description: []notionapi.RichText{},
+					IsInline:    false,
+					Archived:    false,
+					Icon: &notionapi.Icon{
+						Type:  "emoji",
+						Emoji: &emoji,
+					},
+					Cover: &notionapi.Image{
+						Type: "external",
+						External: &notionapi.FileObject{
+							URL: "https://website.domain/images/image.png",
+						},
+					},
 				},
 			},
 		}
diff --git a/testdata/database_create.json b/testdata/database_create.json
index 462451f..2716c87 100644
--- a/testdata/database_create.json
+++ b/testdata/database_create.json
@@ -43,5 +43,7 @@
   "parent": {
     "type": "page_id",
     "page_id": "a7744006-9233-4cd0-bf44-3a49de2c01b5"
-  }
+  },
+  "description": [],
+  "is_inline": false
 }
diff --git a/testdata/database_create_2.json b/testdata/database_create_2.json
index 1315ceb..e3671eb 100644
--- a/testdata/database_create_2.json
+++ b/testdata/database_create_2.json
@@ -43,5 +43,7 @@
     "parent": {
         "type": "block_id",
         "block_id": "a7744006-9233-4cd0-bf44-3a49de2c01b5"
-    }
+    },
+    "description": [],
+    "is_inline": false
 }
\ No newline at end of file
diff --git a/testdata/database_update.json b/testdata/database_update.json
index ad35640..33cebcb 100644
--- a/testdata/database_update.json
+++ b/testdata/database_update.json
@@ -141,5 +141,7 @@
       "type": "url",
       "url": {}
     }
-  }
+  },
+  "description": [],
+  "is_inline": false
 }