Reputation: 51
I would like to ask if there is a way to easily get the number of pages in the database?
Since I didn't find any endpoint for that, I came up with this not very nice solution:
let count = 0
let hasMore = true
let nextCursor = undefined
while (hasMore) {
const result: QueryDatabaseResponse = await notion.databases.query({
database_id: databaseId,
start_cursor: nextCursor ?? undefined,
})
count += result.results.length
hasMore = result.has_more
nextCursor = result.next_cursor
}
Did I miss something in the documentation?
Upvotes: 5
Views: 1339