Skip to content

Type

Source: src/AWS/Keyspaces/Type.ts

An Amazon Keyspaces (for Apache Cassandra) user-defined type (UDT) — a named group of fields usable as a column type in tables of the same keyspace.

UDTs are immutable: any change to the field definitions replaces the type. A type used by a table (or nested in another type) cannot be deleted until its consumers are gone.

Address Type

const address = yield* Type("Address", {
keyspaceName: keyspace.keyspaceName,
fields: [
{ name: "street", type: "text" },
{ name: "city", type: "text" },
{ name: "zip", type: "text" },
],
});

Use the Type in a Table Column

const table = yield* Table("Customers", {
keyspaceName: keyspace.keyspaceName,
columns: [
{ name: "id", type: "uuid" },
{ name: "shipping", type: `frozen<${address.typeName}>` },
],
partitionKeys: ["id"],
});