HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📌
hkob's Notion
/
NotionRubyMapping idea note
NotionRubyMapping idea note
/
Notion Ruby Mapping Public API Reference
Notion Ruby Mapping Public API Reference
/
🧱
Database
🧱

Database

👉
Links (Block base class)
🧱
Page
🧱
Block
🧱
CalloutBlock
🧱
DividerBlock
🧱
Heading1Block
🧱
LinkPreviewBlock
🧱
PdfBlock
🧱
TemplateBlock (Deprecated)
🧱
ToggleHeading2Block
🧱
Database
🧱
BookmarkBlock
🧱
CodeBlock
🧱
EmbedBlock
🧱
Heading2Block
🧱
LinkToPageBlock
🧱
QuoteBlock
🧱
ToDoBlock
🧱
ToggleHeading3Block
🧱
DataSource 🆕 
🧱
BreadcrumbBlock
🧱
ColumnBlock
🧱
EquationBlock
🧱
Heading3Block
🧱
NumberedListItemBlock
🧱
SyncedBlock
🧱
ToggleBlock
🧱
VideoBlock
🧱
List
🧱
BulletedListItemBlock
🧱
ColumnListBlock
🧱
FileBlock
🧱
ImageBlock
🧱
ParagraphBlock
🧱
TableOfContentsBlock
🧱
ToggleHeading1Block
Notion Ruby Mapping Public API Reference
Notion Ruby Mapping Public API Reference

1. Class methods

self.find(id, dry_run: false)

  • [PARAM] id database_id (String)
  • [PARAM(optional)] dry_run: true if you want to create a verification script (Boolean)
  • [EXCEPTION] StandardError throw StandardError when the database is not found.
Database.find(id) creates a Database object with retrieving database API. The created object has database information generated from the JSON response.
Database.find "c37a2c66-e3aa-4a0d-a447-73de3b80c253" # Notion API call # => #<NotionRubyMapping::Database:...> # retrieved Database object
Database.find id, dry_run: true creates shell script using Retrieve a database API for verification.
print Database.find "c37a2c66-e3aa-4a0d-a447-73de3b80c253", dry_run: true # #!/bin/sh # curl 'https://api.notion.com/v1/databases/c37a2c66e3aa4a0da44773de3b80c253' \ # -H 'Notion-Version: 2025-09-03' \ # -H 'Authorization: Bearer '"$NOTION_API_KEY"''=> nil

2. Instance methods

created_time → CreatedTimeProperty

created_time returns the CreatedTimeProperty object for querying database.
db.created_time # => #<NotionRubyMapping::CreatedTimeProperty:...> # CreatedTimeProperty object

date_sources → Array<DataSource>

data_sources returns an Array of DataSources.
db.data_sources #=> #[NotionRubyMapping::DataSource-4f93db514e1d4015b07f876e34c3b0b1, # NotionRubyMapping::DataSource-26cd8e4e98ab81d08983000b28d9e04d]
 

database_title → RichTextArray

database_title returns a RichTextArray object of the database’s title.
db.database_title # => #<NotionRubyMapping::RichTextArray:0x0000000108d7d468>

description → RichTextArray

description returns a RichTextArray object of the database’s description.
db.description # => #<NotionRubyMapping::RichTextArray:0x0000000108bb0130>

description=(text_info)

  • [PARAM] text_info
    • 📃
      The following objects are used for this argument.
      • a String like as “text” (String)
      • an Array of Strings (Array of Strings)
      • a RichTextObject (RichTextObject)
      • an Array of RichTextObjects (Array of RichTextObjects)
      • a RichTextArray (RichTextArray)
description=(text_info) updates the database description using a text_info.
db.description = "another description" db.update_property_schema_json # => {"description"=>[{"type"=>"text", "text"=>{"content"=>"another description", "link"=>nil}, "plain_text"=>"another description", "href"=>nil}]}

is_inline → Boolean

is_inline returns the value true if the database appears in the page as an inline block.
db.is_inline # => true

is_inline=(flag)

is_inline=(flag) updates the database inline flag a flag value.
db.is_inline = true db.update_property_schema_json # => {"is_inline"=>true}

icon → Hash

icon returns JSON hash for the page icon.
db.icon # => {"type"=>"emoji", "emoji"=>"🎉"}

last_edited_time → LastEditedTimeProperty

last_edited_time returns theLastEditedTimeProperty object for querying database.
db.last_edited_time # => #<NotionRubyMapping::LastEditedTimeProperty:...> # LastEditedTimeProperty object

new_record? → Boolean, NilClass

new_record? returns true if the page is generated by create_child_database.
db.new_record? # => nil

save(dry_run: false) →
🧱
Database

  • [PARAM(optional)] dry_run: true if you want to create a verification script
save method updates existing database properties. The database needs to be retrieved using find to prevent existing settings from disappearing.
db = Database.find "c7697137d49f49c2bbcdd6a665c4f921" fp, msp, np, rp, rup, sp = db.properties.values_at "Formula", "MultiSelect", "Number", "Relation", "Rollup", "Select" fp.formula_expression = "pi" msp.add_multi_select_options name: "MS3", color: "blue" np.format = "percent" rp.replace_relation_database database_id: TestConnection::DATABASE_ID, synced_property_name: "Renamed table" rup.function = "average" sp.add_select_options name: "S3", color: "red" db.set_icon emoji: "🎉" db.database_title << "(Added)" db.save # => #<NotionRubyMapping::Database:...> # updated Database object
db.save dry_run: true creates a shell script for verification (Update database API)
db = Database.find "c7697137d49f49c2bbcdd6a665c4f921" np, rup = db.properties.values_at "Number", "Rollup" np.format = "percent" rup.function = "average" print db.save dry_run: true # => #!/bin/sh # curl -X PATCH 'https://api.notion.com/v1/databases/c7697137d49f49c2bbcdd6a665c4f921' \ # -H 'Notion-Version: 2022-02-22' \ # -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \ # -H 'Content-Type: application/json' \ # --data '{"properties":{"Rollup":{"rollup":{"function":"average","relation_property_name":"Relation","rollup_property_name":"NumberTitle"}},"Number":{"number":{"format":"percent"}}}}'

set_cover(url: nil, file_upload_object: nil)

  • [PARAM(optional)] a_url
    • external url (String)
  • [PARAM(optional)] a_fuo
    • file upload object (FileUploadObject)
set_cover can change the page cover using external url or file upload object.
obj.set_cover url: "<https://cdn.profile-image.st-hatena.com/users/hkob/profile.png>" # set external url obj.save fuo = FileUploadObject.new fname: "sample.png" obj.set_cover file_upload_object: fuo obj.save

set_icon(emoji: nil, url: nil, file_upload_object: nil)

  • [PARAM(optional)] an_emoji
    • emoji string (String)
  • [PARAM(optional)] a_url
    • external url (String)
  • [PARAM(optional)] a_fuo
    • file upload object (FileUploadObject)
set_icon can change the page icon using emoji, external url, or file upload object.
obj.set_icon emoji: "💿" # set emoji obj.save obj.set_icon url: "<https://cdn.profile-image.st-hatena.com/users/hkob/profile.png>" # set external url obj.save fuo = FileUploadObject.new fname: "sample.png" obj.set_icon file_upload_object: fuo obj.save