11 ms·
I'm a bit surprised that database query pagination isn't directly mentioned as one of the use cases. The (async) generator wraps the paginated calls to the DB a
by gbuk2013 4y ago
I'm a bit surprised that database query pagination isn't directly mentioned as one of the use cases. The (async) generator wraps the paginated calls to the DB and yields pages or individual documents / rows. It's about as vanilla-CRUD-API scenario as I can think of.
- inglor 4y agoWe've made every node stream async iterable, and we also support all the iterator helpers. If whatever you're using is a Node stream - this works and it exposes an async iterable stream :)
- jitl 4y agoAgreed! We do this in Notion's public API library: for await (const block of iteratePaginatedAPI(notion.blocks.children.list, { block_id: parentBlockId, })) { // Do something with block. } Implemented here: https://github.com/makenotion/notion-sdk-js/blob/90418939a90aa04f52e7bb9b15444cd77b29cc03/src/helpers.ts#L25-L57 https://github.com/makenotion/notion-sdk-js/blob/90418939a90...