0

I am making an application in nodejs in which i have to create cassandra database through CQL.

I have tried to use helenus,cassandra-driver but didn't able to create keyspace through CQL.

I have also tried apollo-cassandra and also able to connect to DB and create keyspace and enter tuples but when we fire queries again after restarting the application then it is showing schime mis-match error.

Which nodejs driver for cassandra is simple and fully supported for CQL?

2 Answers 2

2

Datastax has an official driver in the companys github repo.

https://github.com/datastax/nodejs-driver

The driver is for Apache Cassandra. This driver works exclusively with the Cassandra Query Language version 3 (CQL3) and Cassandra's native protocol.

High level features:

  1. Automatic node discovery
  2. Simple, prepared and batch statement support
  3. Load balancing policies
  4. Failover with retry and reconnection policies
  5. SASL auth support

It works really well and is actively mantained.

Sign up to request clarification or add additional context in comments.

2 Comments

I have already tried to create database using this but didn't able to do so. Can you provide me some running sample code. Actually i have to create different keyspace for different user and then on basis of that, have to executes queries.
Later i can provide a sample but, check the cassandra.yaml of each node and set start_native_transport: true, because the driver talks binary protocol and is not enabled by default.(and restart)
1

Another route (if you prefer not writing the query statement outright in your code) is CassanKnex, it uses the datastax driver to execute queries - usage:

var cassanKnex = require("cassanknex")({
  connection: { // default is 'undefined' 
    contactPoints: ["10.0.0.2"]
  },
  exec: { // default is '{}' 
    prepare: false // default is 'true' 
  }
});

cassanKnex.on("ready", function (err) {

  var qb.createKeyspace("cassanKnexy")
    .withSimpleStrategy(1);
    .exec(function(err, res) {

      if (err)
        console.error("error", err);
      else
        console.log("res", res);

    });
  }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.