Skip to content

Commit 08e4764

Browse files
committed
feat(examples): introducing examples
Signed-off-by: Daniel Boll <danielboll.academico@gmail.com>
1 parent 99716ef commit 08e4764

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

examples/auth.mts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Cluster } from "../index.js"
2+
3+
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"];
4+
5+
const cluster = new Cluster({
6+
nodes,
7+
auth: {
8+
username: "cassandra",
9+
password: "cassandra"
10+
}
11+
});
12+
13+
const session = await cluster.connect();
14+
15+
await session.execute("CREATE KEYSPACE IF NOT EXISTS examples_ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}");
16+
await session.execute("DROP TABLE IF EXISTS examples_ks.auth");
17+
18+
console.log("Ok.");

examples/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"target": "ESNext",
6+
"moduleResolution": "NodeNext"
7+
}
8+
}

0 commit comments

Comments
 (0)