<aside> 👉 Links (Property base class)

ButtonProperty

CheckboxProperty

CreatedByProperty

CreatedTimeProperty

DateProperty

EmailProperty

FilesProperty

FormulaProperty

MultiSelectProperty

LastEditedByProperty

LastEditedTimeProperty

NumberProperty

PeopleProperty

PhoneNumberProperty

Property

RelationProperty

RichTextProperty

RollupProperty

SelectProperty

StatusProperty

TitleProperty

UniqueIdProperty

UrlProperty

VerificationProperty

Notion Ruby Mapping Public API Reference

</aside>

1. Instance methods

relation → Array, Hash

relation returns the raw relation data.

For a Page property, it returns an array of relation objects.

For a Database or DataSource property, it returns the relation property schema.

page.properties["RelationTitle"].relation
# => [{"id"=>"860753bb-6d1f-48de-9621-1fa6e0e31f82"}]

ds.properties["RelationTitle"].relation
# => {
#      "data_source_id"=>"4f93db51-4e1d-4015-b07f-876e34c3b0b1",
#      "type"=>"dual_property",
#      "dual_property"=>{
#        "synced_property_id"=>"%3CnJT",
#        "synced_property_name"=>"RelationTitle"
#      }
#    }

When a relation Page property has has_more: true, Property.create_from_json retrieves the property item list and expands it through List before creating the RelationProperty. Therefore, RelationProperty#relation normally returns the expanded relation array for a Page property.

[P] add_relation(page_id_or_json)

add_relation appends a relation object to a Page property.

When a String is given, it is converted to {"id" => page_id}.

When a Hash is given, it is used as-is. The Hash is expected to follow the Notion API relation object format. NotionRubyMapping does not validate the contents of the Hash.

add_relation sets will_update to true.

page.properties["RelationTitle"].add_relation "new_relation_page_id"
# => [{"id"=>"860753bb-6d1f-48de-9621-1fa6e0e31f82"}, {"id"=>"new_relation_page_id"}]

page.properties["RelationTitle"].add_relation({"id" => "another_new_relation_page_id"})
# => [{"id"=>"860753bb-6d1f-48de-9621-1fa6e0e31f82"}, {"id"=>"new_relation_page_id"}, {"id"=>"another_new_relation_page_id"}]

ds.properties["RelationTitle"].add_relation "page_id"
# ...in `assert_page_property': add_relation can execute only Page property. (StandardError)

Filter usage

These methods return a Query; .filter in the examples reads its generated Hash. Creating a condition does not send an API request or update the property value. [DB/DS] indicates query usage, not an execution-time restriction on the method.

For contains and does_not_contain, pass the related page ID as a UUID string. Replace the example ID with the ID of a related page. Omit condition: and another_type: for an ordinary relation filter; these optional keywords are for nested Formula / Rollup conditions. RelationProperty inherits ContainsDoesNotContain and IsEmptyIsNotEmpty through MultiProperty.

[DB/DS] filter_contains(value) → Query

Creates a Query object whose relation condition matches properties that include the given page ID.