TableV2<Columns>
Generate a new table from the columns and indexes
Deprecated
You should use Table instead as it now allows TableV2 syntax. This will be removed in the next major release.
Extends
Table
<Columns
>
Type parameters
Type parameter | Value |
---|---|
Columns extends ColumnsType | ColumnsType |
Constructors
new TableV2()
new TableV2<Columns>(columns, options?): TableV2<Columns>
Creates a new Table instance.
This constructor supports two different versions:
- New constructor: Using a Columns object and an optional TableV2Options object
- Deprecated constructor: Using a TableOptions object (will be removed in the next major release)
Parameters
Parameter | Type |
---|---|
columns | Columns |
options ? | TableV2Options |
Returns
TableV2
<Columns
>
Inherited from
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 TableV2()
new TableV2<Columns>(options): TableV2<Columns>
Parameters
Parameter | Type |
---|---|
options | TableOptions |
Returns
TableV2
<Columns
>
Inherited from
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 columnMap(): Columns
Returns
Columns
columns
get columns(): Column[]
Returns
Column
[]
indexes
get indexes(): Index[]
Returns
Index
[]
insertOnly
get insertOnly(): boolean
Returns
boolean
internalName
get internalName(): string
Returns
string
localOnly
get localOnly(): boolean
Returns
boolean
name
get name(): string
Returns
string
validName
get validName(): boolean
Returns
boolean
viewName
get viewName(): string
Returns
string
viewNameOverride
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;
}
Member | Type |
---|---|
columns | { |
name : string ; | |
type : undefined | ColumnType ; | |
}[] | |
indexes | { |
columns : { |
`ascending`: `undefined` \| `boolean`;
`name`: `string`;
`type`: [`ColumnType`](../enumerations/ColumnType.md);
\}[];
name
: string
;
}[] |
| insert_only
| boolean
|
| local_only
| boolean
|
| name
| string
|
| view_name
| string
|
Inherited from
validate()
validate(): void
Returns
void
Inherited from
createInsertOnly()
static createInsertOnly(options): Table<ColumnsType>
Parameters
Parameter | Type |
---|---|
options | TableOptions |
Returns
Inherited from
createLocalOnly()
static createLocalOnly(options): Table<ColumnsType>
Parameters
Parameter | Type |
---|---|
options | TableOptions |
Returns
Inherited from
createTable()
static createTable(name, table): Table<ColumnsType>
Create a table.
Parameters
Parameter | Type |
---|---|
name | string |
table | Table <ColumnsType > |
Returns
Inherited from
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.