Skip to content

Commit f2a2692

Browse files
committed
Update README.md
1 parent 28df3b7 commit f2a2692

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.log
44
dist
55
docs
6+
*.tmp
67

78
.yarn/*
89
!.yarn/patches

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,45 @@ A [Trino](https://trino.io) client for [Node.js](https://nodejs.org/).
2323

2424
## Usage
2525

26+
For additional info on all available methods and types have a look at the `API` docs [here](https://regadas.dev/trino-js-client).
27+
28+
### Create a Trino client
29+
2630
```typescript
27-
const trino = Trino.create({
28-
server: 'http://localhost:8080'
31+
const trino: Trino = Trino.create({
32+
server: 'http://localhost:8080',
2933
catalog: 'tpcds',
3034
schema: 'sf100000',
3135
auth: new BasicAuth('test'),
3236
});
37+
```
38+
39+
### Submit a query
40+
41+
```typescript
42+
const iter: Iterator<QueryResult> = await trino.query(
43+
'select * from customer limit 100'
44+
);
45+
```
3346

34-
const iter = await trino.query('select * from customer limit 100');
35-
const data = await iter
47+
### Iterate through the query results
48+
49+
```typescript
50+
for await (const queryResult of iter) {
51+
console.log(queryResult.data);
52+
}
53+
```
54+
55+
### Alternative: map and aggregate the data
56+
57+
```typescript
58+
const data: QueryData[] = await iter
3659
.map(r => r.data ?? [])
3760
.fold<QueryData[]>([], (row, acc) => [...acc, ...row]);
3861
```
3962

63+
## Examples
64+
4065
More usage [examples](https://github.com/regadas/trino-js-client/blob/main/tests/it/client.spec.ts) can be found in the [integration tests](https://github.com/regadas/trino-js-client/blob/main/tests/it/client.spec.ts).
4166

4267
Filipe Regadas (regadas) 2022

0 commit comments

Comments
 (0)