<aside> 👉 Links (Property base class)

Property

ButtonProperty

CreatedTimeProperty

FilesProperty

LastEditedTimeProperty

PeopleProperty

RichTextProperty

StatusProperty

UrlProperty

CheckboxProperty

DateProperty

FormulaProperty

MultiSelectProperty

PhoneNumberProperty

RollupProperty

TitleProperty

VerificationProperty

CreatedByProperty

EmailProperty

LastEditedByProperty

NumberProperty

RelationProperty

SelectProperty

UniqueIdProperty

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_contains(value) → Query

filter_contains creates a Query object for contains filter.

ds.properties["CreatedByTitle"].filter_contains "a_user_id"
# => #<NotionRubyMapping::Query:0x0000000110525498 @filter={"property"=>"CreatedByTitle", "created_by"=>{"contains"=>"a_user_id"}}, @page_size=100, @sort=[], @start_cursor=nil>

### only RollupProperty (none, any, every)
ds.properties["RollupTitle"].filter_contains "abc", condition: "any", another_type: "rich_text"
# => #<NotionRubyMapping::Query:0x0000000105394f30 @filter={"property"=>"RollupTitle", "any"=>{"rich_text"=>{"contains"=>"abc"}}}, @page_size=100, @sort=[], @start_cursor=nil>

filter_does_not_contain(value) → Query

filter_is_not_empty → Query

[P] relation=(page_ids_or_jsons)