DEV Community

Raksix
Raksix

Posted on

Easy Cassandra Driver

I made a cassandra driver but easier than cassandra-driver

Souce Code: Click Me!

Npmjs Page: Click Me!

if you want usage execute:
connection.client.execute("SELECT * FROM ")

İf you find a bug/issue please report Report/Issue Link

Simple Usage:

const cassandra = require("raksix-cassandra")

// connect config payload
const config = {
    secure_path: "./secure-zip-path",
    client_id: "client_id",
    client_secret: "client_secret",
    keyspace: "keyspace"
}

// connect cassandra-driver
const connection = cassandra.connect(config.secure_path, config.client_id, config.client_secret, config.keyspace)

// table payload
const data2 = {
    id: "text PRIMARY KEY",
    name: "text",
    email: "text",
    password: "text"
}


// create table method
connection.create_table("test", data2)


// insert payload
const data3 = {
    id: "1",
    name: "furkan",
    email: "furkan@gmail.com",
    password: "1234"
}


// insert method
connection.instert("test", data3)


// find method
connection.find("test", { name: "furkan" }).then(rs => {
    // result
    console.log(rs.rows)
})
// find all
connection.find_all("test").then(rs => {
    //  result
    console.log(rs.rows)
})

// update method
connection.update("test", { name: "furkan" }, { email: "raksix@raksix.wtf", password: "12346" })
Enter fullscreen mode Exit fullscreen mode

Top comments (0)