Functions

create-database

fn (parent-page-id: Str, title: Str, properties: Map): Map
fn (parent-page-id: Str, title: Str, properties: Map, opts: Map): Map

POST /databases - Create a database under a parent page. properties is the schema, e.g. {Name: {title: {}}, Status: {select: {options: [{name: "Todo"}]}}}.

Example

db ::notion::databases/create-database("59833787-2cf9-4fdf-8782-e53db20768a5", "Roadmap", {
  Name: {title: {}},
  Status: {select: {options: [{name: "Todo"}, {name: "Done"}]}}
})
db.id

get-database

fn (database-id: Str): Map
fn (database-id: Str, opts: Map): Map

GET /databases/{id} - The database schema: property names, types, and options.

Example

db ::notion::databases/get-database("d9824bdc-8445-4327-be8b-5b47500af6ce")
keys(db.properties)

query-database

fn (database-id: Str): Map
fn (database-id: Str, options: Map): Map
fn (database-id: Str, options: Map, opts: Map): Map

POST /databases/{id}/query - Query rows. options supports filter (https://developers.notion.com/reference/post-database-query-filter), sorts, page_size, start_cursor. Returns {results, has_more, next_cursor}.

Example

open ::notion::databases/query-database("d9824bdc-8445-4327-be8b-5b47500af6ce", {
  filter: {property: "Status", status: {does_not_equal: "Done"}},
  sorts: [{property: "Priority", direction: "ascending"}]
})
length(open.results)