Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unset date property #71

Closed
chapterjason opened this issue Apr 27, 2022 · 2 comments · Fixed by #76
Closed

Unset date property #71

chapterjason opened this issue Apr 27, 2022 · 2 comments · Fixed by #76

Comments

@chapterjason
Copy link
Contributor

chapterjason commented Apr 27, 2022

Currently, it isn't possible to unset a date property.
Making it a pointer works.

Date DateObject `json:"date"`

I've created a small workaround that works:

type EmptyDateProperty struct {
	ID   notionapi.ObjectID     `json:"id,omitempty"`
	Type notionapi.PropertyType `json:"type,omitempty"`
	Date *notionapi.DateObject  `json:"date"`
}

func (p EmptyDateProperty) GetType() notionapi.PropertyType {
	return p.Type
}

// [...]

updates["Completed At"] = &EmptyDateProperty{
    ID:   completedAtProperty.ID,
    Type: completedAtProperty.Type,
    Date: nil,
}

// [...]
@jomei
Copy link
Owner

jomei commented May 4, 2022

Hi, @chapterjason !
Could you please provide an example use case where EmptyProperty is needed?

@chapterjason
Copy link
Contributor Author

Hey @jomei

Sure,, I have a small task board with the following properties

  • Choice State with the values Blocked, In Progress and Done
  • Date Completed At

I've built a daemon which sets makest the following changes:

  • if state == "Done" && completedAt == nil set Completed At to now
  • if state != "Done" && completedAt != nil set Completed At to empty or clear as it is called in the UI of notion.

image

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants