Skip to content

Commit 938ee61

Browse files
committed
fetch all entries from notion database
1 parent b83a7a1 commit 938ee61

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

packages/notion-client/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @julianjark/notion-client
22

3+
## 0.9.0
4+
5+
### Minor Changes
6+
7+
- fetch all entries from notion database
8+
39
## 0.8.0
410

511
### Minor Changes

packages/notion-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@julianjark/notion-client",
3-
"version": "0.8.0",
3+
"version": "0.9.0",
44
"description": "Helper client library Notion API",
55
"author": "Julian Jark",
66
"license": "ISC",

packages/notion-client/src/client.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,30 @@ export const getDatabasePages =
4646
database_id: databaseId,
4747
sorts,
4848
filter,
49+
page_size: 100,
4950
});
5051

52+
const results: Awaited<
53+
ReturnType<typeof notion.databases.query>
54+
>["results"] = [];
55+
56+
let cursor: string | undefined;
57+
const shouldContinue = true;
58+
while (shouldContinue) {
59+
const response = await notion.databases.query({
60+
database_id: databaseId,
61+
sorts,
62+
filter,
63+
page_size: 100,
64+
start_cursor: cursor,
65+
});
66+
results.push(...results);
67+
if (!response.next_cursor) {
68+
break;
69+
}
70+
cursor = response.next_cursor;
71+
}
72+
5173
return response.results.filter(isPageObjectResponse);
5274
};
5375

packages/notion-cms/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @julianjark/notion-cms
22

3+
## 0.12.0
4+
5+
### Minor Changes
6+
7+
- fetch all entries from notion database
8+
9+
### Patch Changes
10+
11+
- Updated dependencies
12+
- @julianjark/notion-client@0.9.0
13+
314
## 0.11.1
415

516
### Patch Changes

packages/notion-cms/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@julianjark/notion-cms",
3-
"version": "0.11.1",
3+
"version": "0.12.0",
44
"description": "CMS abstraction for Notion",
55
"author": "Julian Jark",
66
"license": "ISC",

0 commit comments

Comments
 (0)