Skip to content

Table

Source: src/AWS/Keyspaces/Table.ts

An Amazon Keyspaces (for Apache Cassandra) table.

Tables are serverless and provisioned asynchronously (CREATING -> ACTIVE), usually within a minute; the provider waits for ACTIVE (bounded) before returning. Schema mutations (adding columns, changing capacity/TTL/PITR) are applied in place; changing keys replaces the table.

Simple Key-Value Table

const table = yield* Table("Sessions", {
keyspaceName: keyspace.keyspaceName,
columns: [
{ name: "id", type: "uuid" },
{ name: "data", type: "text" },
],
partitionKeys: ["id"],
});

Table with a Clustering Key and TTL

const table = yield* Table("Events", {
keyspaceName: keyspace.keyspaceName,
columns: [
{ name: "device", type: "text" },
{ name: "ts", type: "timestamp" },
{ name: "payload", type: "blob" },
],
partitionKeys: ["device"],
clusteringKeys: [{ name: "ts", orderBy: "DESC" }],
ttlEnabled: true,
defaultTimeToLive: "1 day",
});
const table = yield* Table("Orders", {
keyspaceName: keyspace.keyspaceName,
columns: [
{ name: "id", type: "uuid" },
{ name: "total", type: "int" },
],
partitionKeys: ["id"],
cdcSpecification: {
status: "ENABLED",
viewType: "NEW_AND_OLD_IMAGES",
},
});
// table.latestStreamArn → consume via the TableStreams binding