Skip to main content

Table<Columns>

Extended by

Type Parameters

Type ParameterDefault type
Columns extends ColumnsTypeColumnsType

Constructors

new Table()

new Table<Columns>(columns, options?): Table<Columns>

Creates a new Table instance.

This constructor supports two different versions:

  1. New constructor: Using a Columns object and an optional TableV2Options object
  2. Deprecated constructor: Using a TableOptions object (will be removed in the next major release)

Parameters

ParameterType
columnsColumns
options?TableV2Options

Returns

Table<Columns>

Examples

// New Constructor
const table = new Table(
{
name: column.text,
age: column.integer
},
{ indexes: { nameIndex: ['name'] } }
);
// Deprecated Constructor
const table = new Table({
name: 'users',
columns: [
new Column({ name: 'name', type: ColumnType.TEXT }),
new Column({ name: 'age', type: ColumnType.INTEGER })
]
});

new Table()

new Table<Columns>(options): Table<Columns>

Parameters

ParameterType
optionsTableOptions

Returns

Table<Columns>

Deprecated

This constructor will be removed in the next major release. Use the new constructor shown below instead as this does not show types.

Example

Use this instead ```javascript const table = new Table( { name: column.text, age: column.integer }, { indexes: { nameIndex: ['name'] } } ); ```

Accessors

columnMap

Get Signature

get columnMap(): Columns
Returns

Columns


columns

Get Signature

get columns(): Column[]
Returns

Column[]


indexes

Get Signature

get indexes(): Index[]
Returns

Index[]


insertOnly

Get Signature

get insertOnly(): boolean
Returns

boolean


internalName

Get Signature

get internalName(): string
Returns

string


localOnly

Get Signature

get localOnly(): boolean
Returns

boolean


name

Get Signature

get name(): string
Returns

string


validName

Get Signature

get validName(): boolean
Returns

boolean


viewName

Get Signature

get viewName(): string
Returns

string


viewNameOverride

Get Signature

get viewNameOverride(): undefined | string
Returns

undefined | string

Methods

toJSON()

toJSON(): {
columns: {
name: string;
type: undefined | ColumnType;
}[];
indexes: {
columns: {
ascending: undefined | boolean;
name: string;
type: ColumnType;
}[];
name: string;
}[];
insert_only: boolean;
local_only: boolean;
name: string;
view_name: string;
}

Returns

{
columns: {
name: string;
type: undefined | ColumnType;
}[];
indexes: {
columns: {
ascending: undefined | boolean;
name: string;
type: ColumnType;
}[];
name: string;
}[];
insert_only: boolean;
local_only: boolean;
name: string;
view_name: string;
}
NameType
columns{ name: string; type: undefined | ColumnType; }[]
indexes{ columns: { ascending: undefined | boolean; name: string; type: ColumnType; }[]; name: string; }[]
insert_onlyboolean
local_onlyboolean
namestring
view_namestring

validate()

validate(): void

Returns

void


createInsertOnly()

static createInsertOnly(options): Table<ColumnsType>

Parameters

ParameterType
optionsTableOptions

Returns

Table<ColumnsType>


createLocalOnly()

static createLocalOnly(options): Table<ColumnsType>

Parameters

ParameterType
optionsTableOptions

Returns

Table<ColumnsType>


createTable()

static createTable(name, table): Table<ColumnsType>

Create a table.

Parameters

ParameterType
namestring
tableTable<ColumnsType>

Returns

Table<ColumnsType>

Deprecated

This was only only included for TableV2 and is no longer necessary. Prefer to use new Table() directly.

TODO remove in the next major release.