Class: NotionRubyMapping::Database

Inherits:
Base
  • Object
show all
Defined in:
lib/notion_ruby_mapping/database.rb

Overview

Notion database

Instance Attribute Summary

Attributes inherited from Base

#id, #json

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #assign_property, #children, create_from_json, #icon, #initialize, #json_properties, #new_record?, #properties, #property_values_json, #reload, #restore_from_json, #save, #set_icon, #title, #update_json

Constructor Details

This class inherits a constructor from NotionRubyMapping::Base

Class Method Details

.find(id) ⇒ Object



6
7
8
# File 'lib/notion_ruby_mapping/database.rb', line 6

def self.find(id)
  NotionCache.instance.database id
end

Instance Method Details

#create_child_page(*assign) ⇒ NotionRubyMapping::Base

Parameters:

  • assign (Array<Property, Class, String>)

Returns:



23
24
25
# File 'lib/notion_ruby_mapping/database.rb', line 23

def create_child_page(*assign)
  Page.new assign: assign, parent: {"database_id" => @id}
end

#query_database(query = Query.new) ⇒ Object

Parameters:



11
12
13
14
# File 'lib/notion_ruby_mapping/database.rb', line 11

def query_database(query = Query.new)
  response = @nc.database_query @id, query
  List.new json: response, database: self, query: query
end

#updateNotionRubyMapping::Base



17
18
19
# File 'lib/notion_ruby_mapping/database.rb', line 17

def update
  update_json @nc.update_database_request(@id, property_values_json)
end