open-index/open-npm huggingface dataset:
npm package: @peaka/client
Description: Node client to connect Peaka
Author: Peaka
Latest version: 1.2.3

# Peaka Client
Client for [Peaka](https://peaka.com/), a Zero-ETL data integration platform. 

## Requirements

- Node 12 or newer.

## Install

`npm install @peaka/client` or `yarn add @peaka/client`

## Usage

### Create a Peaka connection

```typescript
import { Peaka, connectToPeaka } from "@peaka/client";

const connection: Peaka = connectToPeaka("<YOUR_API_KEY>", options)
```
NOTE: `options` object and included items are optional.

#### Options Example
```json
{
  "options": {
    "zone": "eu"
  }
}
```
### Options
| option    | default value | possible values | required |
| --------  | -------:      | -------:         | --------:|
| zone      | "us"          | "us" or "eu"    | false    |

### Submit a query

```typescript
import type { QueryResult } from "@peaka/client";

const iter: Iterator<QueryResult> = await connection.query(
  'select * from <CATALOG_NAME>.<SCHEMA_NAME>.<TABLE_NAME> limit 100'
);
```

### Iterate through the query results

```typescript
for await (const queryResult of iter) {
  console.log(queryResult.data);
}
```

### Alternative: map and aggregate the data

```typescript
import type { QueryData } from "@peaka/client";

const data: QueryData[] = await iter
  .map(r => r.data ?? [])
  .fold<QueryData[]>([], (row, acc) => [...acc, ...row]);
```