Interface MapCreateTableColumnDefinition

Overview

Represents the syntax for defining a map column in a table, which has no shorthand/"loose" equivalent.

Of the example format:

columns: {
mapCol: { type: 'map', keyType: 'text', valueType: 'int' },
}

This may then be used through astra-db-ts as a Map<KeyType, ValueType>:

await table.insertOne({
mapCol: new Map([['key1', 1], ['key2', 2]]),
});
The key type

The keyType must, for the time being, be either 'text' or 'ascii'.

Other fields, even those which are still represented as strings in the serialized JSON form (such as uuid) are not supported as key types.

The value type

The valueType may be any scalar type, such as 'int', 'text', or 'uuid'.

Nested collection types are not supported.

Example

import { uuid } from '@datastax/astra-db-ts';

await table.insertOne({
mapCol: new Map([['key1', uuid(4)], ['key2', uuid(4)]]);
});
interface MapCreateTableColumnDefinition {
    keyType: "ascii" | "text";
    type: "map";
    valueType: TableScalarType;
}

Properties

keyType: "ascii" | "text"
type: "map"
valueType: TableScalarType