Code Monkey home page Code Monkey logo

promised-cassandra's Introduction

Promised Cassandra

Build Status

Q promise wrapper for Datastax Cassandra driver

Depends on node v6

Install

npm install --save cassandra-driver promised-cassandra

Featured Cassandra driver functions

Everything. It's proxying the Cassandra driver.

But everything is not tested though.

Tested Cassandra driver functions

  • execute
  • eachRow

Basic usage

// Initiate cassandra connection
const cassandra = require('promised-cassandra');
// If no connection options are passed, connection will default to localhost
// or use CASSANDRA_CONTACT_POINTS environment variable.
const database = cassandra({
    contactPoints: ['127.0.0.1']
});
// or if your options comes from a promise
const database = cassandra(some_promise_that_resolves_an_options_object);

// Execute some CQL
database.execute(
    'SELECT email FROM users WHERE id=?',
    [123]
)
.then(result => {
    // result.rows
    // result.first().email
});

// Run eachRow
database.eachRow('SELECT email FROM users', null, (row => {
    // row.email
})
.then(result => {
    // result.rows
});

Some extra functions

// Create a keyspace if it doesn't already exist and start using it
database.create_keyspace(
    'keyspace-name', // Keyspace name
    {class: 'SimpleStrategy', replication_factor: 1}, // Replication options
    false // Durable writes
)
.then(() => {
    // Keyspace created
});

// Create table if it doesn't already exist
database.create_table(
    'table-name',
    {
        id: 'uuid PRIMARY KEY',
        column: 'text'
    }
)
.then(() => {
    // Table created
);

promised-cassandra's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.