parent
constparent:object
Defined in: src/helpers/parent.helpers.ts:107
Helpers for constructing parent objects for Notion API create operations.
Type Declaration
Section titled “Type Declaration”block: (
blockId) =>object=blockParent
Create a block parent object for comments on blocks.
Parameters
Section titled “Parameters”blockId
Section titled “blockId”string
Returns
Section titled “Returns”object
block_id
Section titled “block_id”block_id:
string
Example
Section titled “Example”parent.block('block-id')database
Section titled “database”database: (
databaseId) =>object
Create a database parent object.
Parameters
Section titled “Parameters”databaseId
Section titled “databaseId”string
Returns
Section titled “Returns”object
database_id
Section titled “database_id”database_id:
string
Example
Section titled “Example”parent.database('database-id')dataSource
Section titled “dataSource”dataSource: (
dataSourceId,databaseId) =>object
Create a data source parent object.
A page with a data source parent needs both data_source_id and
database_id.
Parameters
Section titled “Parameters”dataSourceId
Section titled “dataSourceId”string
databaseId
Section titled “databaseId”string
Returns
Section titled “Returns”object
data_source_id
Section titled “data_source_id”data_source_id:
string
database_id
Section titled “database_id”database_id:
string
Example
Section titled “Example”// Get database info firstconst db = await notion.databases.retrieve('database-id');const dsId = db.dataSources[0].id;
// Create page with data source parentparent.dataSource(dsId, db.id)page: (
pageId) =>object
Create a page parent object.
Parameters
Section titled “Parameters”pageId
Section titled “pageId”string
Returns
Section titled “Returns”object
page_id
Section titled “page_id”page_id:
string
Example
Section titled “Example”parent.page('page-id')workspace
Section titled “workspace”workspace: () =>
object
Create a workspace parent object.
Returns
Section titled “Returns”object
workspace
Section titled “workspace”workspace:
true
Example
Section titled “Example”parent.workspace()Example
Section titled “Example”import { parent } from '@visus-io/notion-sdk-ts';
// Create a page in a databasenotion.pages.create({ parent: parent.database('db-id'), properties: { ... },});
// Create a database under a pagenotion.databases.create({ parent: parent.page('page-id'), properties: { ... },});
// Create a comment on a blocknotion.comments.create({ parent: parent.block('block-id'), rich_text: [...],});