👉
Links (Property base class)
1. Instance methods
[P] add_relation(page_id_or_json)
- [PARAM] page_id_or_json
- page_id: page_id for relation
- json: Hash like as
{"id" ⇒ page_id}
add_relation
of Page property appends a relation using page_id or json.
add_relation
of Database property raises StandardError
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"}]
db.properties["RelationTitle"].add_relation "page_id"
# ...in `assert_page_property': add_relation can execute only Page property. (StandardError)
filter_contains(value) → 🎛️
Query
- [PARAM] value
value_for_filter
filter_contains
creates a Query object for
contains
filter.
db.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)
db.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
- [PARAM] value
value_for_filter
filter_does_not_contain
creates a Query object for
does_not_contain
filter.
db.properties["CreatedByTitle"].filter_does_not_contain "a_user_id"
=> #<NotionRubyMapping::Query:0x0000000110666b68 @filter={"property"=>"CreatedByTitle", "created_by"=>{"does_not_contain"=>"a_user_id"}}, @page_size=100, @sort=[], @start_cursor=nil>
### only RollupProperty (none, any, every)
db.properties["CreatedByTitle"].filter_does_not_contain "abc", condition: "every", another_type: "people"
# => #<NotionRubyMapping::Query:0x000000010533e888 @filter={"property"=>"RollupTitle", "every"=>{"people"=>{"does_not_contain"=>"abc"}}}, @page_size=100, @sort=[], @start_cursor=nil>
filter_is_empty → 🎛️
Query
filter_is_empty
creates a Query object for
is_empty
filter.
db.properties["CreatedByTitle"].filter_is_empty
=> #<NotionRubyMapping::Query:0x0000000106af9ef0 @filter={"property"=>"CreatedByTitle", "created_by"=>{"is_empty"=>true}}, @page_size=100, @sort=[], @start_cursor=nil>
filter_is_not_empty → 🎛️
Query
filter_is_not_empty
creates a Query object for
is_not_empty
filter.
db.properties["CreatedByTitle"].filter_is_not_empty
=> #<NotionRubyMapping::Query:0x00000001104b7290 @filter={"property"=>"CreatedByTitle", "created_by"=>{"is_not_empty"=>true}}, @page_size=100, @sort=[], @start_cursor=nil>
relation → Array, Hash
relation
of Page property returns array of relation page_ids.
relation
of Database property returns hash of relation information.page.properties["RelationTitle"].relation
# => [{"id"=>"860753bb-6d1f-48de-9621-1fa6e0e31f82"}]
db.properties["RelationTitle"].relation
=> {"database_id"=>"1d6b1040-a9fb-48d9-9a3d-041429816e9f", "synced_property_name"=>"Related to Sample table (Column)", "synced_property_id"=>"jZZ>"}
[P] relation=(page_ids_or_jsons)
- [PARAM] page_id_or_json
- page_id: page_id for relation
- [page_id1, page_id2, ...]: page_ids for relation
- json: Hash like as
{"id" ⇒ page_id}
- [json1, json2, ...]: above json’s array
relation=
of Page property sets a relation using page_ids or jsons.
relation=
of Database property raises StandardError
pp = page.properties["RelationTitle"]
pp.relation = "a_id"
pp.relation
# => [{"id"=>"a_id"}]
pp.relation = %w[a_id b_id]
pp.relation
=> [{"id"=>"a_id"}, {"id"=>"b_id"}]
pp.relation = {"id" => "a_id"}
pp.relation
=> [{"id"=>"a_id"}]
pp.relation = [{"id" => "a_id"}, {"id" => "b_id"}]
pp.relation
=> [{"id"=>"a_id"}, {"id"=>"b_id"}]
db.properties["RelationTitle"].relation= "page_id"
# ...in `assert_page_property': relation= can execute only Page property. (StandardError)
[D] relation_database_id
relation=
of Page property raises StandardError.
relation=
of Database property returns related database_id.
page.properties["RelationTitle"].relation_database_id
# ...in `assert_page_property': relation_database_id can execute only Database property. (StandardError)
db.properties["RelationTitle"].relation_database_id
=> "1d6b1040-a9fb-48d9-9a3d-041429816e9f"
[D] replace_relation_database(datbase_id: new_db_id, synced_property_name: new_synced_property_name)
- [PARAM] new_db_id
new database_id for relation
- [PARAM(optional)] new_synced_property_name for dual_property
new synced_property_name for dual_property
replace_relation_database
of Page property raises StandardError.
replace_relation_database
of Database property replaces the database_id for relation.
page.properties["RelationTitle"].replace_relation_database database_id: new_db_id
# ...in `assert_page_property': relation_database_id can execute only Database property. (StandardError)
db.properties["RelationTitle"].replace_relation_database database_id: "new_db_id"
# => {"database_id"=>"new_db_id", "type"=>"single_property", "single_property"=>{}}
db.properties["RelationTitle"].replace_relation_database database_id: "new_db_id", synced_property_name: "name"
=> {"database_id"=>"new_db_id", "type"=>"dual_property", "single_property"=>{}, "dual_property"=>{"synced_property_name"=>"name"}}