今回は久々に機能追加がありました。
is_inline
でインラインデータベースを作成するためのサポートが追加されました。詳細は ここを参照してください。description
によりデータベースの詳細を読み書きするサポートが追加されました。詳細は ここを参照してください。is_inline および description 対応の NotionRubyMapping 0.5.4 をリリースしました。これを使って検証してみます。
page = Page.find "818ee3e7971140888f6dd800e9e96973"
db = page.create_child_database "Sample inline database",
TitleProperty, "Title",
DateProperty, "Date",
NumberProperty, "Price", dry_run: true do |d, dp|
d.is_inline = true
d.description = "This is a sample database."
dp["Price"].format = "yen"
end
まず、上の dry_run で shell script 作ってみました。is_inline と description が設定されているようです。
#!/bin/sh
curl -X POST '<https://api.notion.com/v1/databases>' \\
-H 'Notion-Version: 2022-02-22' \\
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \\
-H 'Content-Type: application/json' \\
--data '{"properties":{"Title":{"title":{}},"Date":{"date":{}},"Price":{"number":{"format":"yen"}}},"title":[{"type":"text","text":{"content":"Sample inline database","link":null},"plain_text":"Sample inline database","href":null}],"parent":{"type":"page_id","page_id":"818ee3e7971140888f6dd800e9e96973"},"is_inline":true,"description":[{"type":"text","text":{"content":"This is a sample database.","link":null},"plain_text":"This is a sample database.","href":null}]}'
dry_run: true を外して、スクリプトを実行したところ、以下のインラインデータベースが作成されました。
description はどこにあるのかと思ったのですが、フルページでデータベースを開くと、タイトルの下に表示されるようです。