Represents the syntax for defining a map column in a table, which has no shorthand/"loose" equivalent.
map
Of the example format:
columns: { mapCol: { type: 'map', keyType: 'text', valueType: 'int' },} Copy
columns: { mapCol: { type: 'map', keyType: 'text', valueType: 'int' },}
This may then be used through astra-db-ts as a Map<KeyType, ValueType>:
astra-db-ts
Map<KeyType, ValueType>
await table.insertOne({ mapCol: new Map([['key1', 1], ['key2', 2]]),}); Copy
await table.insertOne({ mapCol: new Map([['key1', 1], ['key2', 2]]),});
The keyType must, for the time being, be either 'text' or 'ascii'.
keyType
'text'
'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.
uuid
The valueType may be any scalar type, such as 'int', 'text', or 'uuid'.
valueType
'int'
'uuid'
Nested collection types are not supported.
import { uuid } from '@datastax/astra-db-ts';await table.insertOne({ mapCol: new Map([['key1', uuid(4)], ['key2', uuid(4)]]);}); Copy
import { uuid } from '@datastax/astra-db-ts';await table.insertOne({ mapCol: new Map([['key1', uuid(4)], ['key2', uuid(4)]]);});
Overview
Represents the syntax for defining a
map
column in a table, which has no shorthand/"loose" equivalent.Of the example format:
This may then be used through
astra-db-ts
as aMap<KeyType, ValueType>
: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