Skip to content

Commit

Permalink
add result reader to README
Browse files Browse the repository at this point in the history
  • Loading branch information
jraymakers committed Nov 4, 2024
1 parent 7626bc7 commit 6456ee6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api/pkgs/@duckdb/node-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
}
```

### Result Reader

Run and read all data:
```ts
const reader = await connection.runAndReadAll('from test_all_types()');
const rows = reader.getRows();
// OR: const columns = reader.getColumns();
```

Run and read up to (at lesat) some number of rows:
```ts
const reader = await connection.runAndReadUtil('from range(5000)', 1000);
const rows = reader.getRows();
// rows.length === 2048. (Rows are read in chunks of 2048.)
```

Read rows incrementally:
```ts
const reader = await connection.runAndRead('from range(5000)');
reader.readUntil(2000);
// reader.currentRowCount === 2048 (Rows are read in chunks of 2048.)
// reader.done === false
reader.readUntil(4000);
// reader.currentRowCount === 4096
// reader.done === false
reader.readUntil(6000);
// reader.currentRowCount === 5000
// reader.done === true
```

### Inspect Data Types

```ts
Expand Down

0 comments on commit 6456ee6

Please sign in to comment.