MCPcopy Create free account
hub / github.com/brianlovin/github-stars-notion-sync / createDatabase

Function createDatabase

scripts/setup.ts:68–85  ·  view source on GitHub ↗
(notion: Client, parent: any)

Source from the content-addressed store, hash-verified

66}
67
68async function createDatabase(notion: Client, parent: any): Promise<DatabaseHandles> {
69 const db = await notion.request<any>({
70 path: "databases", method: "post",
71 body: {
72 parent,
73 title: [{ type: "text", text: { content: DB_TITLE } }],
74 icon: DB_ICON,
75 initial_data_source: { properties: SCHEMA },
76 },
77 });
78 const dataSourceId = db.data_sources?.[0]?.id;
79 if (!dataSourceId) bail(`Notion created the database but didn't return a data source ID.`);
80 return {
81 databaseId: db.id,
82 dataSourceId,
83 databaseUrl: db.url ?? `https://www.notion.so/${db.id.replace(/-/g, "")}`,
84 };
85}
86
87async function createViews(notion: Client, databaseId: string, dataSourceId: string): Promise<void> {
88 const ds = await notion.request<any>({ path: `data_sources/${dataSourceId}`, method: "get" });

Callers 1

mainFunction · 0.85

Calls 1

bailFunction · 0.85

Tested by

no test coverage detected