Class: Notion::Api::DatabasesMethods

Inherits:
Object
  • Object
show all
Includes:
RequestClient
Defined in:
lib/notion-sdk-ruby/api/databases.rb

Instance Method Summary collapse

Instance Method Details

#create(body) ⇒ Notion::Database

Creates a database as a subpage in the specified parent page, with the specified properties schema. developers.notion.com/reference/create-a-database

Parameters:

  • body (Hash)

Returns:



31
32
33
34
# File 'lib/notion-sdk-ruby/api/databases.rb', line 31

def create(body)
  response = post("/v1/databases", body.to_json)
  Database.new(response.body)
end

#query(id, body) ⇒ Notion::List<Notion::Page>

Gets a list of Pages contained in the database, filtered and ordered according to the filter conditions and sort criteria provided in the request. developers.notion.com/reference/post-database-query

Parameters:

  • id (String)

    database_id

  • body (Hash)

Returns:



21
22
23
24
# File 'lib/notion-sdk-ruby/api/databases.rb', line 21

def query(id, body)
  response = post("/v1/databases/#{id}/query", body.to_json)
  List.new(response.body)
end

#retrieve(id) ⇒ Notion::Database

Retrieves a Database object using the ID specified. developers.notion.com/reference/retrieve-a-database

Parameters:

  • id (String)

    database_id

Returns:



10
11
12
13
# File 'lib/notion-sdk-ruby/api/databases.rb', line 10

def retrieve(id)
  response = get("/v1/databases/#{id}")
  Database.new(response.body)
end

#update(id, body) ⇒ Notion::Database

Updates an existing database as specified by the parameters. developers.notion.com/reference/update-a-database

Parameters:

  • id (String)

    database_id

  • body (Hash)

Returns:



41
42
43
44
# File 'lib/notion-sdk-ruby/api/databases.rb', line 41

def update(id, body)
  response = patch("/v1/databases/#{id}", body.to_json)
  Database.new(response.body)
end