open-index/open-npm huggingface dataset:
npm package: @guejs/adonisjs-cassandra
Description: AdonisJs provider for connect to Cassandra with two packages driver: cassandra-drive and cassanknex.
Author: PT Global Urban Esensial
Latest version: 1.0.7

# AdonisJs Cassandra Provider

[![NPM Version][npm-image]][npm-url]

AdonisJs provider for connect to Cassandra with two packages driver: cassandra-drive and cassanknex.

## Install

```
adonis install @guejs/adonisjs-cassandra
```
or
```
npm install --save @guejs/adonisjs-cassandra
```

## Usage

### Registering provider

Make sure you register the provider inside `start/app.js` file before making use cassandra.

```js
const providers = [
  '@guejs/adonisjs-cassandra/providers/CassandraProvider'
]
```

Once that done you can make use of Cassandra anywhere by importing the cassandra provider.

```js
const Cassandra = use('Cassandra')
```

### Using cassandra-driver
```js
let query = ''
let params = []
await Cassandra.drive.execute(query, params, { prepare: true })
```

### Using cassanknex
```js
let qb = await Cassandra.knex('CASSANDRA_KEYSPACE')
qb.insert({
...
})
.into('table')
.exec({ prepare: true })
```

### Config
The config file `config/cassandra.js` contains all the configuration. Feel free to tweak it as per your needs.

### Environment variables
The configuration file makes use of **Environment variables**, make sure to define them for development and in production too

```
CASSANDRA_HOST=
CASSANDRA_HOST2=
CASSANDRA_PORT=
CASSANDRA_USERNAME=
CASSANDRA_PASSWORD=
CASSANDRA_KEYSPACE=
```

## Thanks

Special thanks to the creator(s) of [AdonisJS](http://adonisjs.com/) for creating such a great framework.

[npm-image]: https://img.shields.io/npm/v/@guejs/adonisjs-cassandra.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@guejs/adonisjs-cassandra