@guejs/adonisjs-cassandra
v1.0.7
Published
AdonisJs provider for connect to Cassandra with two packages driver: cassandra-drive and cassanknex.
Downloads
379
Maintainers
Readme
AdonisJs Cassandra Provider
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.
const providers = [
'@guejs/adonisjs-cassandra/providers/CassandraProvider'
]
Once that done you can make use of Cassandra anywhere by importing the cassandra provider.
const Cassandra = use('Cassandra')
Using cassandra-driver
let query = ''
let params = []
await Cassandra.drive.execute(query, params, { prepare: true })
Using cassanknex
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 for creating such a great framework.