Skip to content

Commit 6456ee6

Browse files
committed
add result reader to README
1 parent 7626bc7 commit 6456ee6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

api/pkgs/@duckdb/node-api/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@ for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
146146
}
147147
```
148148

149+
### Result Reader
150+
151+
Run and read all data:
152+
```ts
153+
const reader = await connection.runAndReadAll('from test_all_types()');
154+
const rows = reader.getRows();
155+
// OR: const columns = reader.getColumns();
156+
```
157+
158+
Run and read up to (at lesat) some number of rows:
159+
```ts
160+
const reader = await connection.runAndReadUtil('from range(5000)', 1000);
161+
const rows = reader.getRows();
162+
// rows.length === 2048. (Rows are read in chunks of 2048.)
163+
```
164+
165+
Read rows incrementally:
166+
```ts
167+
const reader = await connection.runAndRead('from range(5000)');
168+
reader.readUntil(2000);
169+
// reader.currentRowCount === 2048 (Rows are read in chunks of 2048.)
170+
// reader.done === false
171+
reader.readUntil(4000);
172+
// reader.currentRowCount === 4096
173+
// reader.done === false
174+
reader.readUntil(6000);
175+
// reader.currentRowCount === 5000
176+
// reader.done === true
177+
```
178+
149179
### Inspect Data Types
150180

151181
```ts

0 commit comments

Comments
 (0)