Zum Hauptinhalt springen

InsertBuilder

InsertBuilder

Implements

Constructors

Constructor

new InsertBuilder(table?): InsertBuilder

Creates an instance of InsertBuilder.

Parameters

table?

string

the specified table you want to insert

Returns

InsertBuilder

Member Of

InsertBuilder

Properties

toString()

toString: () => string

Generates the SQL Query

Returns

string

  • returns a sql query

Member Of

InsertBuilder

Implementation of

StatementBuilder.toString

Methods

into()

into(table): InsertBuilder

Specifies the table you want to insert data

Parameters

table

string

the specified table you want to insert

Returns

InsertBuilder

Example

insert.into("tbl_Kunden");

Member Of

InsertBuilder


addColumn()

addColumn(columns, surroundWithBrackets?): InsertBuilder

Adds a column or a range of columns to the insert statement. Important: The columns must match with the values. For optimal usage, please use the add function

Parameters

columns

the columns you want to insert with data

string | string[]

surroundWithBrackets?

boolean

(optional) Should surround names with brackets: column -> [column]

Returns

InsertBuilder

  • this instance

See

add.

Examples

insert.addColumn("Kundenname"); // [Kundenname]
insert.addColumn("Kundenname", false); // Kundenname

Member Of

InsertBuilder


addValue()

addValue(values): InsertBuilder

Adds a value or a range of values to the statement. Important: The values must match with the columns. For optimal usage, please use the add function

Parameters

values

an array with values that should be inserted

string | number | Date | (string | number | Date)[]

Returns

InsertBuilder

  • this instance

See

add.

Member Of

InsertBuilder


addRange()

addRange(values): InsertBuilder

Adds a range of columns with their data to the statement

Parameters

values

[string, string | number | Date][]

A tuple or an tuple array with the key that represents the column and the value that represents the data

Returns

InsertBuilder

Example

builder.addRange([ ["ID", 4], ["Kundenname", "Test"] ])

Member Of

InsertBuilder


add()

add(column, value, surroundWithBrackets?): InsertBuilder

Adds a column and value to the statement

Parameters

column

string

A string that represents the column

value

A string or number that contains the value

string | number | Date

surroundWithBrackets?

boolean

(optional) Should surround names with brackets: column -> [column]

Returns

InsertBuilder

  • this instance

Examples

builder.add("KundenEmail", "test@one-unity.de"]) // INSERT INTO tbl_Kunden ( [KundenEmail] )  VALUES ( 'test@one-unity.de' )
builder.add("KundenEmail", "test@one-unity.de"], false) // INSERT INTO tbl_Kunden ( KundenEmail )  VALUES ( 'test@one-unity.de' )

Member Of

InsertBuilder


toSQL()

toSQL(): string

Generates the SQL Query

Returns

string

  • returns a sql query

Member Of

InsertBuilder

Implementation of

StatementBuilder.toSQL


into()

static into(table): InsertBuilder

Specifies the table you want to insert data

Parameters

table

string

the specified table you want to insert

Returns

InsertBuilder

  • returns a new Instance

Static

Example

const insert = InsertBuilder.into("tbl_Kunden");

Member Of

InsertBuilder