-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(types): add most of type supports for the driver (#48)
Signed-off-by: Daniel Boll <[email protected]>
- Loading branch information
1 parent
6fbe40f
commit 1513fad
Showing
30 changed files
with
1,089 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Cluster } from "../../index.js"; | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"]; | ||
|
||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ nodes }); | ||
const session = await cluster.connect(); | ||
|
||
await session.execute( | ||
"CREATE KEYSPACE IF NOT EXISTS bigints WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", | ||
); | ||
await session.useKeyspace("bigints"); | ||
|
||
await session.execute( | ||
"CREATE TABLE IF NOT EXISTS bigints (a bigint, primary key (a))", | ||
); | ||
|
||
await session.execute("INSERT INTO bigints (a) VALUES (?)", [1238773128n]); | ||
|
||
const results = await session.execute("SELECT a FROM bigints"); | ||
console.log(results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Cluster, Float } from "../../index.js"; | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"]; | ||
|
||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ nodes }); | ||
const session = await cluster.connect(); | ||
|
||
await session.execute( | ||
"CREATE KEYSPACE IF NOT EXISTS floats WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", | ||
); | ||
await session.useKeyspace("floats"); | ||
|
||
await session.execute( | ||
"CREATE TABLE IF NOT EXISTS floats (a float, primary key (a))", | ||
); | ||
|
||
await session.execute("INSERT INTO floats (a) VALUES (?)", [new Float(1.1)]); | ||
|
||
const results = await session.execute("SELECT a FROM floats"); | ||
console.log(results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Cluster, List, Uuid } from "../../index.js"; | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"]; | ||
|
||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ nodes }); | ||
const session = await cluster.connect(); | ||
|
||
await session.execute( | ||
"CREATE KEYSPACE IF NOT EXISTS lists WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", | ||
); | ||
await session.useKeyspace("lists"); | ||
|
||
await session.execute( | ||
"CREATE TABLE IF NOT EXISTS lists (a uuid, b list<int>, primary key (a))", | ||
); | ||
|
||
// NOTE: driver is not throwing errors if the return of the function is not used. | ||
await session.execute("INSERT INTO lists (a, b) VALUES (?, ?)", [ | ||
Uuid.randomV4(), | ||
new List<number>([1, 2, 3]), | ||
]); | ||
|
||
const results = await session.execute("SELECT * FROM lists"); | ||
console.log(results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Cluster, Map, Uuid } from "../../index.js"; | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"]; | ||
|
||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ nodes }); | ||
const session = await cluster.connect(); | ||
|
||
await session.execute( | ||
"CREATE KEYSPACE IF NOT EXISTS maps WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", | ||
); | ||
await session.useKeyspace("maps"); | ||
|
||
await session.execute( | ||
"CREATE TABLE IF NOT EXISTS maps (a uuid, b map<text, int>, primary key (a))", | ||
); | ||
|
||
await session.execute("INSERT INTO maps (a, b) VALUES (?, ?)", [ | ||
Uuid.randomV4(), | ||
new Map<string, number>([ | ||
["a", 1], | ||
["b", 2], | ||
["c", 3], | ||
]), | ||
]); | ||
|
||
const results = await session.execute("SELECT * FROM maps"); | ||
console.log(results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Cluster, Set, Uuid } from "../../index.js"; | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"]; | ||
|
||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ nodes }); | ||
const session = await cluster.connect(); | ||
|
||
await session.execute( | ||
"CREATE KEYSPACE IF NOT EXISTS sets WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", | ||
); | ||
await session.useKeyspace("sets"); | ||
|
||
await session.execute( | ||
"CREATE TABLE IF NOT EXISTS sets (a uuid, b set<int>, primary key (a))", | ||
); | ||
|
||
await session.execute("INSERT INTO sets (a, b) VALUES (?, ?)", [ | ||
Uuid.randomV4(), | ||
new Set<number>([1, 2, 3, 1]), | ||
]); | ||
|
||
const results = await session.execute("SELECT * FROM sets"); | ||
console.log(results); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Cluster, Uuid } from "../../index.js"; | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"]; | ||
|
||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ nodes }); | ||
const session = await cluster.connect(); | ||
|
||
await session.execute( | ||
"CREATE KEYSPACE IF NOT EXISTS uuids WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", | ||
); | ||
await session.useKeyspace("uuids"); | ||
|
||
await session.execute( | ||
"CREATE TABLE IF NOT EXISTS uuids (a uuid, primary key (a))", | ||
); | ||
|
||
await session.execute("INSERT INTO uuids (a) VALUES (?)", [Uuid.randomV4()]); | ||
|
||
const results = await session.execute("SELECT a FROM uuids"); | ||
console.log(results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Cluster, Varint } from "../../index.js"; | ||
|
||
const nodes = process.env.CLUSTER_NODES?.split(",") ?? ["127.0.0.1:9042"]; | ||
|
||
console.log(`Connecting to ${nodes}`); | ||
|
||
const cluster = new Cluster({ nodes }); | ||
const session = await cluster.connect(); | ||
|
||
await session.execute( | ||
"CREATE KEYSPACE IF NOT EXISTS varints WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", | ||
); | ||
await session.useKeyspace("varints"); | ||
|
||
await session.execute( | ||
"CREATE TABLE IF NOT EXISTS varints (a varint, primary key (a))", | ||
); | ||
|
||
await session.execute("INSERT INTO varints (a) VALUES (?)", [ | ||
new Varint([0x00, 0x01, 0x02]), | ||
]); | ||
|
||
const results = await session.execute("SELECT a FROM varints"); | ||
console.log(results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.