Module: Notion::Api::Endpoints::Databases
- Included in:
- Notion::Api::Endpoints
- Defined in:
- lib/notion/api/endpoints/databases.rb
Instance Method Summary collapse
-
#database(options = {}) ⇒ Object
Retrieves a Database object using the ID specified in the request.
-
#database_query(options = {}) ⇒ Object
Gets a paginated array of Page object s contained in the requested database, filtered and ordered according to the filter and sort objects provided in the request.
-
#databases_list(options = {}) ⇒ Object
Returns a paginated list of Databases objects for the workspace.
Instance Method Details
#database(options = {}) ⇒ Object
Retrieves a Database object using the ID specified in the request.
Returns a 404 HTTP response if the database doesn’t exist, or if the bot doesn’t have access to the database. Returns a 429 HTTP response if the request exceeds Notion’s Request limits.
16 17 18 19 |
# File 'lib/notion/api/endpoints/databases.rb', line 16 def database( = {}) throw ArgumentError.new('Required arguments :id missing') if [:id].nil? get("databases/#{[:id]}") end |
#database_query(options = {}) ⇒ Object
Gets a paginated array of Page object s contained in the requested database, filtered and ordered according to the filter and sort objects provided in the request.
Filters are similar to the filters provided in the Notion UI. Filters operate on database properties and can be combined. If no filter is provided, all the pages in the database will be returned with pagination.
Sorts are similar to the sorts provided in the Notion UI. Sorts operate on database properties and can be combined. The order of the sorts in the request matter, with earlier sorts taking precedence over later ones.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/notion/api/endpoints/databases.rb', line 47 def database_query( = {}) throw ArgumentError.new('Required arguments :id missing') if [:id].nil? if block_given? Pagination::Cursor.new(self, :database_query, ).each do |page| yield page end else post("databases/#{[:id]}/query", ) end end |
#databases_list(options = {}) ⇒ Object
Returns a paginated list of Databases objects for the workspace.
Paginate through collections of data by setting the cursor parameter to a start_cursor attribute returned by a previous request’s next_cursor. Default value fetches the first “page” of the collection. See pagination for more detail.
66 67 68 69 70 71 72 73 74 |
# File 'lib/notion/api/endpoints/databases.rb', line 66 def databases_list( = {}) if block_given? Pagination::Cursor.new(self, :databases_list, ).each do |page| yield page end else get('databases', ) end end |