# adonis-clickhouse

> AdonisJS addon for ClickHouse

Latest version **1.0.1** (published 2024-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install adonis-clickhouse
pnpm add adonis-clickhouse
yarn add adonis-clickhouse
bun add adonis-clickhouse
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-03-07 |
| First published | 2024-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.16.0 |
| Dependencies | 2 |
| Unpacked size | 22.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chieh |
| Maintainers | shiny |

## Links

- npm: https://www.npmjs.com/package/adonis-clickhouse
- npm.io page: https://npm.io/package/adonis-clickhouse

## Dependencies (2)

- [@poppinss/utils](https://npm.io/package/@poppinss/utils.md) ^6.7.2
- [@clickhouse/client](https://npm.io/package/@clickhouse/client.md) ^0.2.10

## Recent versions

- 1.0.1 (latest) — 2024-03-07
- 1.0.0 — 2024-03-07
- 1.0.0-alpha.3 — 2024-03-07
- 1.0.0-pre.2 — 2024-03-07
- 1.0.0-pre.1 — 2024-03-07

## README

# ClickHouse for AdonisJS v6

> [!CAUTION]
> This package is not compatible with AdonisJS v5.

A third-party wrapper for `@clickhouse/client` in AdonisJS v6.

<del>Copied a lot from</del> Inspired a lot by [@adonijs/redis](https://github.com/adonisjs/redis/).

## Installation

```bash
npm install --save adonis-clickhouse
node ace configure adonis-clickhouse
```

## Configuration

You can change it in `config/clickhouse.ts`, it's all same with `createClient` Configuration.
here is the details: https://clickhouse.com/docs/en/integrations/language-clients/javascript#configuration

## How to import
As it is a container service, you can init it by
```typescript
await app.container.make('clickhouse')
```
or
```typescript
import clickhouse from 'adonis-clickhouse/services/main'
```
The way same as `@adonisjs/redis`.

### Query
The imported clickhouse actully is a instance of `@clickhouse/client` Client, hence those codes are equal:

An example of `adonis-clickhouse`
```typescript
import clickhouse from 'adonis-clickhouse/services/main'
await clickhouse.query({
    /* QueryParams */
})
```

Equaled offical library example
```typescript
import { createClient } from '@clickhouse/client'
const client = createClient({
  /* configuration */
})
await client.query({
    /* QueryParams */
})
```

## Multi Database Instances
You can config the multi databases and use `manager` to connect it.

```typescript
import { manager } from 'adonis-clickhouse/services/main'
// Change main to the name you defined.
const client = manager.connect('main')
await client.query({
    /* QueryParams */
})
```

## Documentation

See [Offical ClickHouse JS Library](https://clickhouse.com/docs/en/integrations/language-clients/javascript)

## Lisence
the MIT

---
_Source: https://npm.io/package/adonis-clickhouse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
