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

Add name field to DB (page) props

This commit is contained in:
David Stotijn 2021-12-17 18:03:53 +01:00
parent 9fc88f927b
commit 52e133b4e8
3 changed files with 34 additions and 0 deletions

View File

@ -467,6 +467,7 @@ func TestQueryDatabase(t *testing.T) {
"Date": { "Date": {
"id": "Q]uT", "id": "Q]uT",
"type": "date", "type": "date",
"name": "Date",
"date": { "date": {
"start": "2021-05-18T12:49:00.000-05:00", "start": "2021-05-18T12:49:00.000-05:00",
"end": null "end": null
@ -475,6 +476,7 @@ func TestQueryDatabase(t *testing.T) {
"Name": { "Name": {
"id": "title", "id": "title",
"type": "title", "type": "title",
"name": "Name",
"title": [ "title": [
{ {
"type": "text", "type": "text",
@ -498,11 +500,13 @@ func TestQueryDatabase(t *testing.T) {
"Age": { "Age": {
"id": "$9nb", "id": "$9nb",
"type": "number", "type": "number",
"name": "Age",
"number": 42 "number": 42
}, },
"People": { "People": {
"id": "1#nc", "id": "1#nc",
"type": "people", "type": "people",
"name": "People",
"people": [ "people": [
{ {
"id": "be32e790-8292-46df-a248-b784fdf483cf", "id": "be32e790-8292-46df-a248-b784fdf483cf",
@ -518,6 +522,7 @@ func TestQueryDatabase(t *testing.T) {
"Files": { "Files": {
"id": "!$9x", "id": "!$9x",
"type": "files", "type": "files",
"name": "Files",
"files": [ "files": [
{ {
"name": "foobar.pdf" "name": "foobar.pdf"
@ -527,31 +532,37 @@ func TestQueryDatabase(t *testing.T) {
"Checkbox": { "Checkbox": {
"id": "49S@", "id": "49S@",
"type": "checkbox", "type": "checkbox",
"name": "Checkbox",
"checkbox": true "checkbox": true
}, },
"URL": { "URL": {
"id": "93$$", "id": "93$$",
"type": "url", "type": "url",
"name": "URL",
"url": "https://example.com" "url": "https://example.com"
}, },
"Email": { "Email": {
"id": "xb3Q", "id": "xb3Q",
"type": "email", "type": "email",
"name": "Email",
"email": "jane@example.com" "email": "jane@example.com"
}, },
"PhoneNumber": { "PhoneNumber": {
"id": "c2#Q", "id": "c2#Q",
"type": "phone_number", "type": "phone_number",
"name": "PhoneNumber",
"phone_number": "867-5309" "phone_number": "867-5309"
}, },
"CreatedTime": { "CreatedTime": {
"id": "s#0s", "id": "s#0s",
"type": "created_time", "type": "created_time",
"name": "Created time",
"created_time": "2021-05-24T15:44:09.123Z" "created_time": "2021-05-24T15:44:09.123Z"
}, },
"CreatedBy": { "CreatedBy": {
"id": "49S@", "id": "49S@",
"type": "created_by", "type": "created_by",
"name": "Created by",
"created_by": { "created_by": {
"id": "be32e790-8292-46df-a248-b784fdf483cf", "id": "be32e790-8292-46df-a248-b784fdf483cf",
"name": "Jane Doe", "name": "Jane Doe",
@ -565,11 +576,13 @@ func TestQueryDatabase(t *testing.T) {
"LastEditedTime": { "LastEditedTime": {
"id": "x#0s", "id": "x#0s",
"type": "last_edited_time", "type": "last_edited_time",
"name": "Last edited time",
"last_edited_time": "2021-05-24T15:44:09.123Z" "last_edited_time": "2021-05-24T15:44:09.123Z"
}, },
"LastEditedBy": { "LastEditedBy": {
"id": "x9S@", "id": "x9S@",
"type": "last_edited_by", "type": "last_edited_by",
"name": "Last edited by",
"last_edited_by": { "last_edited_by": {
"id": "be32e790-8292-46df-a248-b784fdf483cf", "id": "be32e790-8292-46df-a248-b784fdf483cf",
"name": "Jane Doe", "name": "Jane Doe",
@ -583,6 +596,7 @@ func TestQueryDatabase(t *testing.T) {
"Calculation": { "Calculation": {
"id": "s(4f", "id": "s(4f",
"type": "formula", "type": "formula",
"name": "Calculation",
"formula": { "formula": {
"type": "number", "type": "number",
"number": 42 "number": 42
@ -591,6 +605,7 @@ func TestQueryDatabase(t *testing.T) {
"Relation": { "Relation": {
"id": "Cxl[", "id": "Cxl[",
"type": "relation", "type": "relation",
"name": "Relation",
"relation": [ "relation": [
{ {
"id": "2be9597f-693f-4b87-baf9-efc545d38ebe" "id": "2be9597f-693f-4b87-baf9-efc545d38ebe"
@ -600,6 +615,7 @@ func TestQueryDatabase(t *testing.T) {
"Rollup": { "Rollup": {
"id": "xyA}", "id": "xyA}",
"type": "rollup", "type": "rollup",
"name": "Rollup",
"rollup": { "rollup": {
"type": "array", "type": "array",
"array": [ "array": [
@ -655,6 +671,7 @@ func TestQueryDatabase(t *testing.T) {
"Date": notion.DatabasePageProperty{ "Date": notion.DatabasePageProperty{
ID: "Q]uT", ID: "Q]uT",
Type: notion.DBPropTypeDate, Type: notion.DBPropTypeDate,
Name: "Date",
Date: &notion.Date{ Date: &notion.Date{
Start: mustParseDateTime("2021-05-18T12:49:00.000-05:00"), Start: mustParseDateTime("2021-05-18T12:49:00.000-05:00"),
}, },
@ -662,6 +679,7 @@ func TestQueryDatabase(t *testing.T) {
"Name": notion.DatabasePageProperty{ "Name": notion.DatabasePageProperty{
ID: "title", ID: "title",
Type: notion.DBPropTypeTitle, Type: notion.DBPropTypeTitle,
Name: "Name",
Title: []notion.RichText{ Title: []notion.RichText{
{ {
Type: notion.RichTextTypeText, Type: notion.RichTextTypeText,
@ -678,11 +696,13 @@ func TestQueryDatabase(t *testing.T) {
"Age": notion.DatabasePageProperty{ "Age": notion.DatabasePageProperty{
ID: "$9nb", ID: "$9nb",
Type: notion.DBPropTypeNumber, Type: notion.DBPropTypeNumber,
Name: "Age",
Number: notion.Float64Ptr(42), Number: notion.Float64Ptr(42),
}, },
"People": notion.DatabasePageProperty{ "People": notion.DatabasePageProperty{
ID: "1#nc", ID: "1#nc",
Type: notion.DBPropTypePeople, Type: notion.DBPropTypePeople,
Name: "People",
People: []notion.User{ People: []notion.User{
{ {
ID: "be32e790-8292-46df-a248-b784fdf483cf", ID: "be32e790-8292-46df-a248-b784fdf483cf",
@ -698,6 +718,7 @@ func TestQueryDatabase(t *testing.T) {
"Files": notion.DatabasePageProperty{ "Files": notion.DatabasePageProperty{
ID: "!$9x", ID: "!$9x",
Type: notion.DBPropTypeFiles, Type: notion.DBPropTypeFiles,
Name: "Files",
Files: []notion.File{ Files: []notion.File{
{ {
Name: "foobar.pdf", Name: "foobar.pdf",
@ -707,11 +728,13 @@ func TestQueryDatabase(t *testing.T) {
"Checkbox": notion.DatabasePageProperty{ "Checkbox": notion.DatabasePageProperty{
ID: "49S@", ID: "49S@",
Type: notion.DBPropTypeCheckbox, Type: notion.DBPropTypeCheckbox,
Name: "Checkbox",
Checkbox: notion.BoolPtr(true), Checkbox: notion.BoolPtr(true),
}, },
"Calculation": notion.DatabasePageProperty{ "Calculation": notion.DatabasePageProperty{
ID: "s(4f", ID: "s(4f",
Type: notion.DBPropTypeFormula, Type: notion.DBPropTypeFormula,
Name: "Calculation",
Formula: &notion.FormulaResult{ Formula: &notion.FormulaResult{
Type: notion.FormulaResultTypeNumber, Type: notion.FormulaResultTypeNumber,
Number: notion.Float64Ptr(float64(42)), Number: notion.Float64Ptr(float64(42)),
@ -720,26 +743,31 @@ func TestQueryDatabase(t *testing.T) {
"URL": notion.DatabasePageProperty{ "URL": notion.DatabasePageProperty{
ID: "93$$", ID: "93$$",
Type: notion.DBPropTypeURL, Type: notion.DBPropTypeURL,
Name: "URL",
URL: notion.StringPtr("https://example.com"), URL: notion.StringPtr("https://example.com"),
}, },
"Email": notion.DatabasePageProperty{ "Email": notion.DatabasePageProperty{
ID: "xb3Q", ID: "xb3Q",
Type: notion.DBPropTypeEmail, Type: notion.DBPropTypeEmail,
Name: "Email",
Email: notion.StringPtr("jane@example.com"), Email: notion.StringPtr("jane@example.com"),
}, },
"PhoneNumber": notion.DatabasePageProperty{ "PhoneNumber": notion.DatabasePageProperty{
ID: "c2#Q", ID: "c2#Q",
Type: notion.DBPropTypePhoneNumber, Type: notion.DBPropTypePhoneNumber,
Name: "PhoneNumber",
PhoneNumber: notion.StringPtr("867-5309"), PhoneNumber: notion.StringPtr("867-5309"),
}, },
"CreatedTime": notion.DatabasePageProperty{ "CreatedTime": notion.DatabasePageProperty{
ID: "s#0s", ID: "s#0s",
Type: notion.DBPropTypeCreatedTime, Type: notion.DBPropTypeCreatedTime,
Name: "Created time",
CreatedTime: notion.TimePtr(mustParseTime(time.RFC3339Nano, "2021-05-24T15:44:09.123Z")), CreatedTime: notion.TimePtr(mustParseTime(time.RFC3339Nano, "2021-05-24T15:44:09.123Z")),
}, },
"CreatedBy": notion.DatabasePageProperty{ "CreatedBy": notion.DatabasePageProperty{
ID: "49S@", ID: "49S@",
Type: notion.DBPropTypeCreatedBy, Type: notion.DBPropTypeCreatedBy,
Name: "Created by",
CreatedBy: &notion.User{ CreatedBy: &notion.User{
ID: "be32e790-8292-46df-a248-b784fdf483cf", ID: "be32e790-8292-46df-a248-b784fdf483cf",
Name: "Jane Doe", Name: "Jane Doe",
@ -753,11 +781,13 @@ func TestQueryDatabase(t *testing.T) {
"LastEditedTime": notion.DatabasePageProperty{ "LastEditedTime": notion.DatabasePageProperty{
ID: "x#0s", ID: "x#0s",
Type: notion.DBPropTypeLastEditedTime, Type: notion.DBPropTypeLastEditedTime,
Name: "Last edited time",
LastEditedTime: notion.TimePtr(mustParseTime(time.RFC3339Nano, "2021-05-24T15:44:09.123Z")), LastEditedTime: notion.TimePtr(mustParseTime(time.RFC3339Nano, "2021-05-24T15:44:09.123Z")),
}, },
"LastEditedBy": notion.DatabasePageProperty{ "LastEditedBy": notion.DatabasePageProperty{
ID: "x9S@", ID: "x9S@",
Type: notion.DBPropTypeLastEditedBy, Type: notion.DBPropTypeLastEditedBy,
Name: "Last edited by",
LastEditedBy: &notion.User{ LastEditedBy: &notion.User{
ID: "be32e790-8292-46df-a248-b784fdf483cf", ID: "be32e790-8292-46df-a248-b784fdf483cf",
Name: "Jane Doe", Name: "Jane Doe",
@ -771,6 +801,7 @@ func TestQueryDatabase(t *testing.T) {
"Relation": notion.DatabasePageProperty{ "Relation": notion.DatabasePageProperty{
ID: "Cxl[", ID: "Cxl[",
Type: notion.DBPropTypeRelation, Type: notion.DBPropTypeRelation,
Name: "Relation",
Relation: []notion.Relation{ Relation: []notion.Relation{
{ {
ID: "2be9597f-693f-4b87-baf9-efc545d38ebe", ID: "2be9597f-693f-4b87-baf9-efc545d38ebe",
@ -780,6 +811,7 @@ func TestQueryDatabase(t *testing.T) {
"Rollup": notion.DatabasePageProperty{ "Rollup": notion.DatabasePageProperty{
ID: "xyA}", ID: "xyA}",
Type: notion.DBPropTypeRollup, Type: notion.DBPropTypeRollup,
Name: "Rollup",
Rollup: &notion.RollupResult{ Rollup: &notion.RollupResult{
Type: notion.RollupResultTypeArray, Type: notion.RollupResultTypeArray,
Array: []notion.DatabasePageProperty{ Array: []notion.DatabasePageProperty{

View File

@ -85,6 +85,7 @@ type File struct {
type DatabaseProperty struct { type DatabaseProperty struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Type DatabasePropertyType `json:"type"` Type DatabasePropertyType `json:"type"`
Name string `json:"name,omitempty"`
Title *EmptyMetadata `json:"title,omitempty"` Title *EmptyMetadata `json:"title,omitempty"`
RichText *EmptyMetadata `json:"rich_text,omitempty"` RichText *EmptyMetadata `json:"rich_text,omitempty"`

View File

@ -39,6 +39,7 @@ type DatabasePageProperties map[string]DatabasePageProperty
type DatabasePageProperty struct { type DatabasePageProperty struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Type DatabasePropertyType `json:"type,omitempty"` Type DatabasePropertyType `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Title []RichText `json:"title,omitempty"` Title []RichText `json:"title,omitempty"`
RichText []RichText `json:"rich_text,omitempty"` RichText []RichText `json:"rich_text,omitempty"`