Skip to content

parent

const parent: object

Defined in: src/helpers/parent.helpers.ts:107

Helpers for constructing parent objects for Notion API create operations.

block: (blockId) => object = blockParent

Create a block parent object for comments on blocks.

string

object

block_id: string

parent.block('block-id')

database: (databaseId) => object

Create a database parent object.

string

object

database_id: string

parent.database('database-id')

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.

string

string

object

data_source_id: string

database_id: string

// Get database info first
const db = await notion.databases.retrieve('database-id');
const dsId = db.dataSources[0].id;
// Create page with data source parent
parent.dataSource(dsId, db.id)

page: (pageId) => object

Create a page parent object.

string

object

page_id: string

parent.page('page-id')

workspace: () => object

Create a workspace parent object.

object

workspace: true

parent.workspace()
import { parent } from '@visus-io/notion-sdk-ts';
// Create a page in a database
notion.pages.create({
parent: parent.database('db-id'),
properties: { ... },
});
// Create a database under a page
notion.databases.create({
parent: parent.page('page-id'),
properties: { ... },
});
// Create a comment on a block
notion.comments.create({
parent: parent.block('block-id'),
rich_text: [...],
});