Module: Notion::Http::Endpoints::DatabaseMethods
- Included in:
- Client
- Defined in:
- lib/notion/http/endpoints/database_methods.rb
Overview
Notion::Http::Client.new(token: NOTION_TOKEN).retrieve_a_database(DATABASE_ID)
Instance Method Summary collapse
-
#create_a_database(options = {}) ⇒ Object
Creates a database as a subpage in the specified parent page, with the specified properties schema.
-
#query_a_database(options = {}) ⇒ Object
Gets a list of Pages contained in the database, filtered and ordered according to the filter conditions and sort criteria provided in the request.
-
#retrieve_a_database(options = {}) ⇒ Object
Retrieves a database object.
-
#update_a_database(options = {}) ⇒ Object
Update the title, description, or properties of a specified database.
Instance Method Details
#create_a_database(options = {}) ⇒ Object
Creates a database as a subpage in the specified parent page, with the specified properties schema.
25 26 27 28 29 30 |
# File 'lib/notion/http/endpoints/database_methods.rb', line 25 def create_a_database( = {}) raise Notion::Errors::ParamError, "Missing required params :parent.page_id" if .dig(:parent, :page_id).nil? raise Notion::Errors::ParamError, "Missing required params :parent.properties" if [:properties].nil? post("databases", ) end |
#query_a_database(options = {}) ⇒ Object
Gets a list of Pages contained in the database, filtered and ordered according to the filter conditions and sort criteria provided in the request.
17 18 19 20 21 22 |
# File 'lib/notion/http/endpoints/database_methods.rb', line 17 def query_a_database( = {}) raise Notion::Errors::ParamError, "Missing required params :database_id" if [:database_id].nil? database_id = .delete(:database_id) post("databases/#{database_id}/query", ) end |
#retrieve_a_database(options = {}) ⇒ Object
Retrieves a database object.
9 10 11 12 13 |
# File 'lib/notion/http/endpoints/database_methods.rb', line 9 def retrieve_a_database( = {}) raise Notion::Errors::ParamError, "Missing required params :database_id" if [:database_id].nil? get("databases/#{[:database_id]}") end |
#update_a_database(options = {}) ⇒ Object
Update the title, description, or properties of a specified database. Properties define the columns of a database.
33 34 35 36 37 38 |
# File 'lib/notion/http/endpoints/database_methods.rb', line 33 def update_a_database( = {}) raise Notion::Errors::ParamError, "Missing required params :database_id" if [:database_id].nil? database_id = .delete(:database_id) patch("databases/#{database_id}", ) end |