await db.createTable('my_table', {
definition: {
columns: {
id: 'uuid',
name: { type: 'text' },
set: { type: 'set', valueType: 'text' },
},
primaryKey: ...,
},
});
The loose column definition is a shorthand for the strict version, and follows the following example form:
columns: {
textCol: 'text',
uuidCol: 'uuid',
}
In this form, the key is the column name, and the value is the type of the scalar column.
If you need to define a column with a more complex type (i.e. for maps, sets, lists, and vectors), you must use the strict column definition.
Plus, while it still provides autocomplete, the loose column definition does not statically enforce the type of the column, whereas the strict column definition does.
The strict column definition is the more structured way to define a column, and follows the following example form:
columns: {
uuidCol: { type: 'uuid' },
mapCol: { type: 'map', keyType: 'text', valueType: 'int' },
listCol: { type: 'list', valueType: 'text' },
vectorCol: { type: 'vector', dimension: 3 },
}
In this form, the key is the column name, and the value is an object with a type
field that specifies the type of the column.
The object may also contain additional fields that are specific to the type of the column:
map
, you must specify the keyType
and valueType
fields.keyType
must, for the time being, be either 'text'
or 'ascii'
.valueType
must be a scalar type.list
s and set
s, you must specify the valueType
field.valueType
must be a scalar type.vector
s, you must specify the dimension
field.service
field to enable vectorize.
Overview
Represents the syntax for defining a new column through the bespoke Data API schema definition syntax, in which there are two branching ways to define a column.